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

Support onError hook during the init phase #220

Closed
sobolevn opened this issue Jul 14, 2018 · 3 comments
Closed

Support onError hook during the init phase #220

sobolevn opened this issue Jul 14, 2018 · 3 comments

Comments

@sobolevn
Copy link
Contributor

What problem does this feature solve?

Currently the suggested way to bind your own error hooks is by defining a custom plugin:

// plugins/auth.js
export default function({ $auth }) {
  $auth.onError((error, name, endpoint) => {
    console.error(name, error)
  })
}

And then extending the auth config like so:

{
  modules: {
    '@nuxtjs/auth'
  },
  auth: {
     plugins: [ '~/plugins/auth.js' ]
  }
}

But, the problem is that when some error happens during $auth.init().
In this case _errorListeners is not yet populated, so there's no way to intercept this error.

In my case this is token expiration error from one of the oauth providers.

How about providing any mechanism to handle errors during init()?

This feature request is available on Nuxt community (#c177)
@ghost ghost added the cmty:feature-request label Jul 14, 2018
@gijswijs
Copy link

I have this exact same issue. I want to handle an error during init() gracefully, but there's no proper way to load error listeners before the Init.

@gijswijs
Copy link

I though it would be best to just go ahead and create a PR myself.

@pi0
Copy link
Member

pi0 commented May 30, 2019

This should be fixed in v4.6.0 by #234. Please ping here if the issue still exists.

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

4 participants