Interceptor for 404 with error method not working
See original GitHub issueVersion
Reproduction link
https://github.com/msonowal/nuxt-bug-reproduce-link
Steps to reproduce
add this in
plugins
dir make file name it axios.js
and add the link in nuxt config plugins array visit any route whose axios calls are 404
axios.js file content below
export default function({ $axios, error }) {
$axios.onError((responseError) => {
if (responseError.response.status === 404) {
error({ statusCode: 404, message: 'Post not found from interceptor' })
}
})
}
What is expected ?
show the error response with 404 code as defined in the nuxt app Post not found from interceptor
but
not redirect to 301
What is actually happening?
it is showing default nuxt error
NuxtServerError
Request failed with status code 404
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:10 (1 by maintainers)
Top Results From Across the Web
NUXT JS Interceptor for 404 or any errors with error method ...
This seem to work for me. _.vue async asyncData(context) { ... try { const response = await context.$axios(options); ... } catch (error) ...
Read more >Angular — intercept your http errors - Level Up Coding
With the so-called HttpInterceptor , Angular provides us a way to transform http requests and responses. Through the interface, we can implement the...
Read more >Angular: Handle HTTP Errors using Interceptors
An error interceptor is a special type of interceptor which is used for handling errors that arise while making an HTTP request. The...
Read more >How to Handle Errors with Angular Error Handling - Code Maze
The page that handles the 404 error is already created, so, let's continue on by creating a 500 (Internal server error) component.
Read more >NUXT JS Interceptor for 404 or any errors with error method ...
Coding example for the question NUXT JS Interceptor for 404 or any errors with error method not working-Vue.js.
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
Anything happening on this one? Or are there any way to solve this? I would like to show a proper error page to the user without redirecting (which works), or show the nuxt default error page.
This problem is still occurring. Please reopen the issue.