Comments (5)
The simplest thing I can think of that might work is to change:
} catch (err) {
result = err.response;
}
into
} catch (err) {
// Non-HTTP failures should be re-thrown. This will handle lower level network failures
if (!err.response) throw err;
// HTTP level failures can be translated into fetch style responses
result = err.response;
}
Is it possible for you to try a change like that and see if it fixes your problem?
from axios-fetch.
That's a case I haven't thought of before. This project is based around having axios-fetch behave just like fetch
does, so my first question is "How does fetch
behave in the offline case?".
If you know that, I have a feeling that the code here could be updated to match the fetch behavior if .response
is missing
from axios-fetch.
So it seems like it fails with a TypeError, and is one of the few cases that fetch
returns a rejected promise.
Here is a post I found detailing the different error messages based on the browser: https://medium.com/vinh-rocks/how-to-handle-networkerror-when-using-fetch-ff2663220435
And here is the line of a test case in node-fetch
for handling a network failure: https://github.com/node-fetch/node-fetch/blob/master/test/main.js#L110
So what would be your preferred path forward?
from axios-fetch.
That appears to work! Would you like me to open a PR with those changes, or would it be simpler for you to just commit the change yourself?
from axios-fetch.
Unless someone feels otherwise going to go ahead and close this issue. The proposed solution was implemented in #78 and released in @lifeomic/[email protected]
#79
from axios-fetch.
Related Issues (20)
- Form-data not serializing correctly
- buildAxiosFetch not adding X-XSRF-TOKEN header on requests HOT 3
- node-fetch vulnerability HOT 1
- Error fetching and displaying characters from other languages HOT 12
- TypeError: Cannot read properties of undefined (reading 'name') HOT 1
- Support 204 no-content for node 18
- Unable to integrate with Angular
- Not working in IE11 HOT 5
- An in-range update of nock is breaking the build 🚨 HOT 2
- axios-fetch won't let me intercept 401 failed requests HOT 3
- 1.5.0 Release breaks Apollo HOT 4
- `.finally()` is not a function HOT 5
- GET requests have data as string "undefined"
- Unable to import useAxiosFetch as an ES6 module HOT 1
- Promise<Response>' is not assignable to type 'AxiosFetch'
- Abort requests via FetchInit signal abort HOT 1
- `fetch` should also accept `Request` object
- Do not require `node-fetch` for browser targets HOT 1
- Update package.json types to reference index.d.ts HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axios-fetch.