Trying to filter an object from an array using another array in a JSON feed that has one array with objects and object within objects:
members = [
{
id: 1,
name: "Ruta"
},
{
id: 2,
name: "Paul"
},
{
id: 3,
name: "Raymond"
}
]
roles = {
0: {
id: 1,
title: "admin",
member: [1,2],
status:
},
1: {
id: 2,
title: "editor",
member: [1]
},
2: {
id: 3,
title: "moderator",
member: [3]
}
}
The attempted approach to get roles by member is not working as intended
members() {
return Object.values(members).filter((el) => {
return this.roles.map((id) => { return id }).includes(el)
})
},
Displayed in Vue
<div v-for="(member) in members">
<div>
{{member.name}}
</div>
<div v-for="(role) in roles">
{{role.title}}
</div>
</div>
Desired result:
Result:
Ruta
- admin
- editor
Paul
- admin
Raymond
- moderator