Home

Issue: 1667

asyncData called after calling error in middleware

[issue link]

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?

This bug report is available on Nuxt.js community (#c1492)