Nuxt.js asyncData Axios Handle 404

March 9, 2020
export default {
  async asyncData ({ $axios, params, error }) {
    try {
      const {data } = await $axios.get(`/data/page-${params.id}.json`)
      return data
    }
    catch (err) {
      error({statusCode: 404, message: 'Page not found'})
    }
  }
}
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.