How to send multiple requests in asyncData
[issue link]Sorry, I’m not good at english!
This is my asyncData method :
export default {
async asyncData({ query, error }) {
return axios.all([
axios.get('/api/post/page/0'),
axios.get('/api/post/count/published')
]).then(axios.spread((pageRes, countRes) => {
return {
posts: pageRes.data.list,
total: countRes.data.result
}
})).catch((err) => {
error({ statusCode: 404, message: err.message })
})
}
}
I want to send multiple requests in asyncData,but it doesn’t work,here is error information:
(node:9360) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: __WEBPACK_IMPORTED_MODULE_2__plugins_axios__.a.all is not a function