Skip to content

Commit

Permalink
check for error.response in axios interceptors
Browse files Browse the repository at this point in the history
  • Loading branch information
garethredfern committed Jan 11, 2021
1 parent a564303 commit 41c3b99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/services/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ apiClient.interceptors.response.use(
return response;
},
function (error) {
if (error.response.status === 401 || error.response.status === 419) {
if (
error.response &&
(error.response.status === 401 || error.response.status === 419)
) {
store.dispatch("auth/logout");
}
return Promise.reject(error);
Expand Down
5 changes: 4 additions & 1 deletion src/services/AuthService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ authClient.interceptors.response.use(
return response;
},
function (error) {
if (error.response.status === 401 || error.response.status === 419) {
if (
error.response &&
(error.response.status === 401 || error.response.status === 419)
) {
store.dispatch("auth/logout");
}
return Promise.reject(error);
Expand Down

0 comments on commit 41c3b99

Please sign in to comment.