Assume that the response.data I have is:
{
"data": {
"person1": [
{
"name": ....
"age": xx
}
],
"person2": [
{
"name": ....
"age": xx
}
],
"person3": [
{
"name": ....
"age": xx
}
]
}
}
In my attempt to add a gender
field to each person using the map function, I wrote this code:
axios
.get('...')
.then(response => (this.people = [response.data].map(person => {
person.gender = "";
return person;
})))
However, only one gender
field gets added to the entire response.data
rather than to each individual person. What could be the issue here?
The desired outcome should look like this:
{
"data": {
"person1": [
{
"name": ....
"age": xx
},
gender: ""
],
"person2": [
{
"name": ....
"age": xx
},
gender: ""
],
"person3": [
{
"name": ....
"age": xx
},
gender: ""
]
}
}