Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interceptor for 404 with error method not working #310

Closed
msonowal opened this issue Nov 30, 2019 · 10 comments
Closed

Interceptor for 404 with error method not working #310

msonowal opened this issue Nov 30, 2019 · 10 comments

Comments

@msonowal
Copy link

msonowal commented Nov 30, 2019

Version

v5.8.0

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

This bug report is available on Nuxt community (#c305)
@ghost ghost added the cmty:bug-report label Nov 30, 2019
@ola-skriubakken
Copy link

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.

@msonowal
Copy link
Author

this is a much needed feature as it gives ability to modularize lot of implementations

@bravebirdy
Copy link

the same error I got, any solutions?

@Akulko
Copy link

Akulko commented Oct 5, 2020

Same error, any updates?

@aaronhuisinga
Copy link

This is an issue we have definitely struggled with as well.

@msonowal
Copy link
Author

msonowal commented Dec 2, 2020

@pi0
Can you look into this as it is because of the underlying axios update only, Can you see if you can solve on it

@pi0
Copy link
Member

pi0 commented Dec 2, 2020

Hi @msonowal. I believe v5.12.3 uses latest version of axios (v0.21.0). Trying to locally check.

@msonowal
Copy link
Author

msonowal commented Dec 2, 2020

@pi0 sorry it was the wrong thread I replied and pinged sorry for the mistakes
Actually I was referring to this
nuxt-community/auth-module#809

@msonowal msonowal closed this as completed Dec 2, 2020
@timothycraig
Copy link

timothycraig commented Dec 5, 2020

I am still experiencing this issue. Calling the error function from within $axios.onError does not seem to work.

"@nuxtjs/axios": "^5.12.3",
"nuxt": "^2.14.9",

@Scino
Copy link

Scino commented Jan 22, 2021

This problem is still occurring.
Please reopen the issue.

"@nuxtjs/axios": "^5.12.5",
"nuxt": "^2.14.12",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants