I need help figuring out why my computed property is returning an empty array.
Let me explain:
My EditPost.vue
file has data like so:
data() {
return {
posts: [
{
post_id: 1,
process_id: 4,
post_name: "ACME Widget",
poc_list: [1, 2]
},
{
post_id: 2,
process_id: 1,
post_name: "XYZ Widget",
poc_list: 3
},
{
post_id: 3,
process_id: 2,
post_name: "ABC Bar",
poc_list: null
},
{
post_id: 4,
process_id: 3,
post_name: "Foo Bar",
poc_list: [1, 3]
}
],
userProfiles: [
{
uid: 1,
firstname: "Claiborne",
lastname: "Heberden",
email: "cheberden0@gravatar.com"
},
{
uid: 2,
firstname: "Gerick",
lastname: "Tetla",
email: "gtetla1@whitehouse.gov"
},
{
uid: 3,
firstname: "Raymund",
lastname: "Espy",
email: "respy2@freewebs.com"
},
{
uid: 4,
firstname: "Dilly",
lastname: "Dimitriev",
email: "ddimitriev3@skype.com"
},
...snip...
],
with a computed property like so:
computed: {
contacts() {
const contacts = this.userProfiles.filter(
contact => this.posts.poc_list === contact.uid
);
return contacts;
}
}
Despite the posts
array containing values for some of the poc_lists
properties, the computed property contacts
is not returning the values.
Full demo here : Click POSTS -->Edit (next to ACME WIDGET) and you'll see "Current Contacts" section is not populated, despite there being data.
Thanks for any help anyone can provide!