Skip to content

Commit

Permalink
modify handleResponse.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jainvedant392 committed Dec 16, 2023
1 parent b5b902f commit 308710d
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/Utils/request/handleResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,14 @@ export default function handleResponse(
return;
}

// 5xx errors
if (res.status >= 500 && res.status < 600) {
console.error("Server error", res);
notify?.Error({ msg: error?.detail || "Something went wrong...!" });
return;
}

// 400/406 Bad Request
if (res.status === 400 || res.status === 406) {
notify?.BadRequest({ errs: error });
return;
}

// Other 400 Errors
if (res.status >= 400) {
// Other Errors between 400-599 (inclusive)
if (res.status >= 400 && res.status < 600) {
// Invalid token
if (!silent && error?.code === "token_not_valid") {
navigate(`/session-expired?redirect=${window.location.href}`);
Expand Down

0 comments on commit 308710d

Please sign in to comment.