Interceptors and unhandled promise rejection
See original GitHub issueSummary
I am using a interceptor to handle errors globally but I am still getting “Unhandled promise rejection” errors on the console for every request.
axios.interceptors.response.use(
response => response,
error => {
console.log(error.message);
return Promise.reject(error);
}
----
axios.get('some-url').then(response => /* handle response */);
----
> Error Message
> Unhandled promise rejection Error: "Error message"
Context
- axios version: 0.18.0
- Environment: Firefox 64, Linux
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
How to handle unhandledrejection errors using axios
Axios is a great library, but unhandled promise rejections can be a problem. ... If you look at the interceptor, we are handling...
Read more >Handling a Promise reject in axios interceptor - Stack Overflow
Having trouble dealing with a specific case of an error, seems like my understanding of promises is flawed. Central error handling in axios ......
Read more >Preventing unhandled promise rejections in async functions
How to prevent unhandled promise rejections when using async/ await. ... unhandledRejection RequestError: HTTP request error. at ...
Read more >keywords:unhandledRejection - npm search
Track the list of currently unhandled promise rejections. unhandled · unhandledRejection · rejected · promises · jamestalmage. published 0.4.1 • 6 years ago ......
Read more >Processing Request | Alexa Skills Kit - Amazon Developer
Request handlers, request and response interceptors, and error handlers are all ... accepts HandlerInput and returns a Response or Promise<Response> .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is exactly what I was trying to avoid. All error handling should be taken care of in the interceptor. I would like to avoid the boilerplate of adding an empty catch in every request.
@guilhermehn Then every request has a result that doesn’t match the result it was expecting. I think a lot of people, myself included would like to do something like log the user out on a 401 response and not have it resolve or reject.