I'm new to Vuejs, I can't figure out how to build a nested array from 2 axios request, I know that there is a better method to achieve the goal... with this code I build 2 separate array, one for productList (with all products of the single shop) and one for shopName (with all shop_urls). I need to use array.map for nested request because I want to build a array of products foreach shop_url
import axios from 'axios';
export default
{
name: 'Product',
data: () => ({
key: 'mySecretKey',
productsList: [],
shopName: [],
errors: [],
}),
mounted() {
axios.get('https://shop.domain.org/api/shop_urls?display=full&output_format=JSON', {
auth: {
username: this.key
},
})
.then(response => response.data.shop_urls.map((val) => {
this.shopName.push(val.virtual_uri)
axios.get('https://shop.domain.org/' + val.virtual_uri + '/api/products?display=full&output_format=JSON', {
auth: {
username: this.key
},
})
.then(response => this.productsList.push(response.data.products))
.catch(e => this.errors.push(e))
}))
}
}

{ 'val' : val, 'products': products }