Skip to content

Commit

Permalink
refactor: catch get status for undefined response
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Mar 30, 2022
1 parent 308fbb7 commit b4dac11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/api/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export const fallbackToPublic = (
return request()
.then(({ data }) => fallbackForArray(data, publicRequest))
.catch((error) => {
if (FALLBACK_TO_PUBLIC_FOR_STATUS_CODES.includes(error.response.status)) {
if (
FALLBACK_TO_PUBLIC_FOR_STATUS_CODES.includes(error.response?.status)
) {
return publicRequest()
.then(({ data }) => data)
.catch((e) => returnFallbackDataOrThrow(e, options?.fallbackData));
Expand Down

0 comments on commit b4dac11

Please sign in to comment.