my code is :
return await axios
.all(requests)
.then(
axios.spread(async (...responses) => {
let fish = [...responses].map((e) => e.data.results);
let newFish = Object.assign({}, ...fish);
console.log(fish, 'and', newFish);
}),
)
a console.log of fish shows:
[(Object of 100 keys), (Object of 100 keys),(Object of 100 keys),(Object of 70 keys)]
but a console.log of newFish instead of being the desired : (Object of 370 keys)
shows (object of 100 keys)
This suggests object. assign is overwriting instead of combining.
Why does it do this?
I need to do
return Object.addign({},...responses)
and have this combine all the objects into one object
more info:
OBJECT WITH 100 keys:
all objects
All have a unique id and are alphabetically ordered. every value is completely unique.
Object with 100 keys is a combination of the last object with 100 keys and the last object that has only 70 keys.
