I have a scenario where I need to extract specific data from an object returned by an API request. The object contains a property called drinks that holds an array of drink objects, each with an id and name property. I want to create an array of objects containing only the id and name properties of each drink.
One approach I've come up with is as follows:
const {drinks} = await [api request]
const arrDrinks = drinks.map((drinkObj, i) => {
return {drinkObj.idDrink, drinkObj.strDrink}
})
I'm wondering if there's a way to achieve this in a more concise manner using nested destructuring?