I have table list of organization and table review of each organization then I want to calculate the average rate of each organization (one of the attributes in review table) This is JSON file that I have
{
id: 17,
name_org: "AAA company",
picture: "default.jpg",
headerpic: "no-preview.png",
type: "hardware,software,network",
review: [
{
review_id: 3,
org_id: 17,
user_id: 2,
description: "Not bad",
rating: 5,
},
{
review_id: 4,
org_id: 17,
user_id: 2,
description: "Good",
rating: 3,
}
]
},
{
id: 18,
name_org: "US company",
picture: "default.jpg",
headerpic: "no-preview.png",
type: "hardware,software,network",
rating: 0,
review: [
{
review_id: 5,
org_id: 18,
user_id: 2,
description: "Well",
rating: 5,
}
]
}
I want to plus every rating in each organization and divide sum of rating with the number of rating (AVG) then show AVG in each organization
methods: {
getOrgData() {
axios.get("api/listorgs").then(response => {
this.ListOrgs = response.data;
});
}
},
data() {
return {
ListOrgs: []
};
},
Can you tell me about that syntax?