Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
fix: add checks for offline scenarios #417 (#418)
Browse files Browse the repository at this point in the history
  • Loading branch information
fny committed Sep 14, 2021
1 parent 7ec2630 commit b4a8cc9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/http.ts
Expand Up @@ -315,7 +315,15 @@ const defaultFetch = ({ url, method, headers, data }: Request): Promise<RequestR
data: response.data,
headers: response.headers,
}))
.catch((error) => Promise.reject(error.response.data))
.catch((error) => {
if (error.response) {
return Promise.reject(error.response.data)
}
if (error.request) {
return Promise.reject(error.request)
}
return Promise.reject(error)
})

export const parseResponse = <T>(
response: RequestResponse,
Expand Down

0 comments on commit b4a8cc9

Please sign in to comment.