Static GitHub Issues

[1667] asyncData called after calling error in middleware

prev: How to fix UglifyJS error `Unexpected token: punc ())`
next: Failed to find '~assets/styles/....css'

Hi guys!

Looks like it's really simple, but I don't find any info in the docs.

I have middleware for handling errors that can be in nuxtServerInit:

export default ({store, error}) => {
  if (store.state.serverError) {
    error(store.state.serverError)
  }
}

What I expect I thought that if I call error in middleware than Nuxt stop render matched layouts/pages and show Error page (I use simple custom layouts/error.vue template)

What I got When I call error in middleware Nuxt show Error page, then continue to call asyncData of the matched page in the background. As result, I see the error page, but API server receives unnecessary calls.

How can I tell Nuxt to stop calling asyncData after calling error in the middleware?

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This bug report is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1492">#c1492</a>)</em></sub></div>