Answer the question
In order to leave comments, you need to log in
Nuxt Vue Apollo. How to redirect to a 404 page in case of an error?
In asyncData() we can redirect with nuxtContext.error({statusCode:404, message: '...'})
In apollo I try to do something like this,
apollo: {
pets: {
prefetch: true,
query: gql`
query {
allPets {
id
name
}
}
`,
update: (data) => data.allPets,
error(errorData) {
this.$root.error({ statusCode: 400, message: 'Error 400. Bad request' });
},
},
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question