Skip to content

Commit

Permalink
guard clause for api error (#11436)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkeye217 authored May 19, 2024
1 parent c156030 commit bca01cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web/src/api/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export function ApiProvider({ children, options }: ApiProviderType) {
return axios.get(path, { params }).then((res) => res.data);
},
onError: (error, _key) => {
if ([401, 302, 307].includes(error.response.status)) {
if (
error.response &&
[401, 302, 307].includes(error.response.status)
) {
window.location.href =
error.response.headers.get("location") ?? "login";
}
Expand Down

0 comments on commit bca01cb

Please sign in to comment.