[Vuejs]-Nuxt – Dynamic route generation returns status 400

0👍

Figured it out.

The issue was with the asyncData function in the component.

The function was like so:

async asyncData({ $axios, params }) {
    const { data } = await $axios.get(`/companies/${params.id}`)
    return { company: data.data }

but I should have used the payload like so:

async asyncData({ $axios, payload, params }) {
    if (payload) {
        return { company: payload }
    } else {
        const { data } = await $axios.get(`/companies/${params.id}`)
        return { company: data.data }
    }
}

Leave a comment