So I have an array that has an object inside of it due to eloquent relationship in laravel. So the array looks something like this:
Documents:
[
{
"id": 6,
"name": "document",
"supplier": {
"id": 5,
"name": "H.B.C",
}
},
{
"id": 5,
"name": "document",
"supplier": {
"id": 5,
"name": "H.B.C",
}
},
{
"id": 4,
"name": "document",
"supplier": {
"id": 4,
"name": "Avrora",
}
}
]
Now I'm trying to use lodash to get unique suppliers so in the above example I would want to get back H.B.C and Avrora without another H.B.C.
What I'm trying:
CollectionSuppliers () {
return uniq(this.Documents.supplier.map(({ name }) => name))
},
but im getting an error:
Cannot read properties of undefined (reading 'map')