I have this array that's a response from an endpoint that looks like this:
{
"dates": [
{
"date": "02-06-2021",
"product": [
{
"id": "a1",
"quantity": 10,
"price": 10.99
]
},
{
"id": "b2",
"quantity": 43,
"price": 17.99
]
}]
}
Is there a way where we can simply get the id and quantity for each product together? I know how to get it separately but not sure if it's possible to get it together:
var fetchData = UrlFetchApp.fetch(url, options);
var idData = JSON.parse(fetchData.getContentText());
var getIdData = idData.dates.map(dates => {return dates.product.map(product => {return product.id})});
var getQuantityData = idData.dates.map(dates => {return dates.product.map(product => {return product.quantity})});