I have an array of objects that contain a property called rates and inside each objects rates array are id's (among other properties, not shown here for simplicity). How can I map these id's to a new array so that I have a record of all id's returned in all objects rates?
const sampleResponse = [
{
id: '123',
rates: [{ id: '123' }, { id: '456' }]
},
{
id: '456',
rates: [{ id: '789' }, { id: 'ABC' }]
},
{
id: '789',
rates: [{ id: 'DEF' }, { id: 'GHI' }]
}
]
Expected Result
const result = ['123', '456', '789', 'ABC', 'DEF', 'GHI']