I have a function which fetches data from the database and sets them in an array. But the issue here is that the array created here returns an array object with length 0
my Code
let products = [];
item.order_items.map((x) => {
Axios.get(api + `/order-items/${x.id}`, {
headers: {
Authorization: "Bearer " + user.token,
},
}).then((res) => products.push(res.data.product));
});
console.log(products);
which makes the array non-iterable... Is there any fix for this