I have an action where I fetch data from 2 API endpoints. But I can't seem to return both of them and I don't understand why.
if (product.ok && stock.ok) {
const stockData = await stock.json();
const productData = await product.json();
return {
statusCode: 200,
body: JSON.stringify({
stock: stockData,
product: productData,
}),
};
} else {
throw new Error(`HTTP error! status: ${product.status}`);
}
This doesn't work for example. But if I do simply:
body: await stock.json()
or
body: await product.json()
Then it does work.
Anyone know why I can't return both at the same time?