Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task_8_solution #321

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: added alerts for 401 and 403 statusCodes
  • Loading branch information
RamanMukhin committed Oct 13, 2021
commit 05c2946a6e4a503a749df28feea0f249d84ae09e
16 changes: 13 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -13,9 +13,19 @@ axios.interceptors.response.use(
return response;
},
function(error) {
if (error?.response?.status === 400) {
alert(error.response.data?.data);
}
const statusCode = error?.response?.status;

switch (statusCode) {
case 400:
alert(error.response.data?.data);
break;
case 401:
alert('Unauthorized');
break;
case 403:
alert('Forbidden');
break;
};

return Promise.reject(error?.response ?? error);
}