2๐
โ
I assume your API methods return a Promise. You should use Promise.all
to wait until both promises are resolved, then return one object containing all the data that nuxt should set:
var res1 = getCategories()
var res2 = getProducts()
return Promise.all(re1, res2).then(function ([data1, data2]) {
return Object.assign({}, data1, data2)
})
the resulting object will look like this:
{
categories: [ /* data from getCategories() */]
allProducts: [ /* data from getProducts () */ ]
}
๐คLinus Borg
Source:stackexchange.com