Reputation: 568
Right now vue inside mounted
function calls a napi and gets the value for teambytime2
. When it fetch the values using an api it looks like
Below is the axios get url used to fetch the data and pass it on to this.teamByTime2
.
axios.get(https://usemyapi90.com/currentDate).then(response =>
(
this.teamByTime2 = response.data
));
Structure for the fetched data is below
> teamByTime2
>> 0
>>> Booker
>>> Player
id
updatedAt
enter code here
>> 1
>>> Booker
>>> Player
id
updatedAt
Any suggestion on how to move object structure for Booker
inside the Player
?
> teamByTime2
>> 0
>>> Player
>>>> Booker
id
updatedAt
enter code here
>> 1
>>> Player
>>>> Booker
id
updatedAt
Upvotes: 0
Views: 95
Reputation: 906
If you have access to the api code you can directly modify the data output, if you don't have access then you could do something like this:
for(let i=0; i < response.data.length; i++){
let item = data[i]
item.Booker.Player = item.Player
//if you wanna delete from main object
delete item.Player
//push in the array
this.teamByTime2.push(item)
}
Upvotes: 1