I am trying to iterate over an array of people and call an api which returns a new age which I will override the age and then merge with dogs array. The code looks like this:
const dogs = [{name:'Chichi', age:2}, {name:'Yayo', age:4}];
const people = [{name:'Mike', age:23}, {name:'John', age:45}];
const modifiedPeople = people.map(person => {
getNewAge(person).pipe(map(newAge=> {return person.age = newAge}));
return [...dogs, modifiedPeople];
})
This always returns an empty modifiedPeople. How can I perform this operation with RxJs in ES6