I'm trying to do for loop in an object array. This is my code
private async rightsOverview() {
let item: any[] = [];
const prod = await fetchFromApi<ProductionBaseType>(`/productions/${id}/right-contracts`)
const rightOverviewuser = await Promise.all(prod.map(async right => {
const rightData = await fetchFromApi<ProductionBaseType>(`/productions/${id}/right-contracts/${right.id}/rights`)
item.push({
id: right.id,
rightData: rightData,
prod: right
});
return item
}))
console.log(item)
this.productions = rightOverviewuser
}
I have two API calls in this function and combined values in one object, till here it is working fine. Now i have the issue how can print values on the front end.
I did the console how i can see the values are printing
Console:
[{
id: "",
prod: {object},
rightData: {object}
}]
Then i tried to loop through like this but it's not returning the values how i need them.
<right-overview-list-item
v-for="production in productions"
:key="production.id"
:production="production"
/>
<div class="overview-list-item">
{{ production.prod.toCompanyType.name }}
</div>
<div class="overview-list-item">
{{ production.rightData.endDate }}
</div>
I hope you understand what i want. If question is unclear please feel free to ask i will try to explain as much as i can.