问题
I have a Nuxt project, in nuxt.config.js file, I have a function like this:
generate: {
async routes() {
function postRoutes() {
return axios
.post('https://my-server.com/api/posts')
.then((r) => r.data.map((post) => {
// I log post data here, it exist
console.log(post)
return {
route: `post/${post.id}`,
payload: 'post'
}
}))
}
const response = await axios
.all([postRoutes()])
.then(function (results) {
const merged = [].concat(...results)
return merged
})
return response
}
},
Then, in pages/post/_slug.vue, in asyncData, when receiving payload object, it returns undefined
async asyncData({ params, error, payload }) { {
console.log(payoad) // return undefined
}
I don't know whether I pass the payload the wrong way or something wrong with Nuxt payload, please help !! thank you in advance
来源:https://stackoverflow.com/questions/65739496/nuxt-generate-payload-undefined