Skip to content

Commit

Permalink
chore(typescript) defensive check (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbo47 authored Jul 24, 2020
1 parent 60218da commit 5d7ee32
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/services/Staffing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,17 @@ export class Staffing {
return response;
},
async (error: AxiosError) => {
// Tracking
const errorResponse: AxiosResponse = error.response;
const timing: { start: number; url: string } = (errorResponse.config as any)._timing || {};
if (Staffing.trackingCallback && timing) {
Staffing.trackingCallback(timing.url, new Date().getTime() - timing.start);
}
// Check if Unauthorized Error
if (error.response.status === 401) {
Staffing.unauthorized.next(error);
if (error && error.response) {
// Tracking
const errorResponse: AxiosResponse = error.response;
const timing: { start: number; url: string } = (errorResponse.config as any)._timing || {};
if (Staffing.trackingCallback && timing) {
Staffing.trackingCallback(timing.url, new Date().getTime() - timing.start);
}
// Check if Unauthorized Error
if (error.response.status === 401) {
Staffing.unauthorized.next(error);
}
}
return Promise.reject(error);
},
Expand Down

0 comments on commit 5d7ee32

Please sign in to comment.