Static GitHub Issues

[1998] [Request] Ability to cancel navigation from asyncData without error page

prev: UnhandlesPromiseRejectionWarning - Request failed status 403
next: Uncaught ReferenceError from plugin file

When handling in-browser errors inside asyncDatafunctions , I want to handle certain errors using pop up alerts rather than navigating to a full error page.

Using axios module, I can show the alert just fine, however the problem is that if I don't throw an error the route and new page continues to load without data. If i do throw an error, the error page loads behind the alert, but navigation stops as intended.

What I would like is either access to the next() function inside asyncData, or an ability to specify in the error object that it has already been handled so no further error page is needed.

Alternatively - any suggestions on how to override the error code in client.js welcomed.

example 1 - navigation continues

if (ctx.isClient) {
    const swal = require('sweetalert2')
    swal({
      type: 'error',
      title: error.title,
      html: error.message
    })
  } else {
    return Promise.reject(error)
  }

example 2 - error page shown

if (ctx.isClient) {
    const swal = require('sweetalert2')
    swal({
      type: 'error',
      title: error.title,
      html: error.message
    })
}
return Promise.reject(error)
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1773">#c1773</a>)</em></sub></div>