Comments (3)
I've never seen axios-auth-refresh before. Seems like a very practical helper library. I'm not sure about why it wouldn't work, but I'd be happy to review a PR if you have an environment to reproduce and debug the problem.
from axios-fetch.
We had the same issue and I eventually tracked it down to this here;
Line 26 in bb0031b
This line basically stops axios from entering the "error" side of the interceptors chain.
What it should be is this; https://github.com/axios/axios/blob/c7329fefc890050edd51e40e469a154d0117fc55/lib/defaults.js#L79-L81
Which would correctly enter the "error" side of the response interceptor.
I think the reason this line was added was due to the usage of await rather than promises?
from axios-fetch.
I ran into this same issue and agree with @SimeonC that validateStatus: () => true
is the culprit. I think the reason it was there is because of the way the Fetch API is implemented:
The Promise returned from fetch() won’t reject on HTTP error status even if the response is an HTTP 404 or 500. Instead, it will resolve normally (with ok status set to false), and it will only reject on network failure or if anything prevented the request from completing.
I think a fix would be to remove the custom validateStatus
(and thus default to the one referenced by @SimeonC), and wrap the request
in a try...catch
instead:
axios-fetch/src/index.js [starting at line 21]
const config = transfomer({
url: input,
method: init.method || 'GET',
data: init.body instanceof FormData ? init.body : String(init.body),
headers: lowerCasedHeaders,
// validateStatus: () => true
}, input, init);
// const result = await axios.request(config);
let result;
try {
result = await axios.request(config);
} catch (err) {
result = err.response;
}
I'll submit a PR with this change for review.
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
- 1.5.0 Release breaks Apollo HOT 4
- `.finally()` is not a function HOT 5
- GET requests have data as string "undefined"
- Error raised if someone goes offline and attempts a request HOT 5
- 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.