Answer the question
In order to leave comments, you need to log in
How to handle vue + ssr 404 errors?
Hello.
There is an application on vue + ssr. There is a page, for example, with a product.
I can't figure out what to do if the product is not in the database.
I took the vue + ssr config here
And so. There is a component product.vue
Actions are called in asyncData
async asyncData({store, route}) {
await store.dispatch('GET_PRODUCT', route.params.id);
},
GET_PRODUCT: async ({ commit }, id) => {
try {
const RES = await productApi.GET_PRODUCT(id);
await commit('SET_PRODUCT', RES.data);
} catch (e) {
console.log(e.response);
}
},
{ error: '404 error' }
$router.push({name: '404'})
$router
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