I have this javascript object:
{
"recommendations": [
{
"thing": "spiderman",
"weight": 1.6666666666666667,
"last_actioned_at": "2019-05-17T23:06:54+01:00",
"last_expires_at": "2020-06-06T01:00:00+01:00",
"people": [
"bob",
"alice"
]
},
{
"thing": "xmen",
"weight": 1.6666666666666667,
"last_actioned_at": "2019-05-17T23:06:54+01:00",
"last_expires_at": "2020-06-06T01:00:00+01:00",
"people": [
"alice",
"bob"
]
},
{
"thing": "barbie",
"weight": 1,
"last_actioned_at": "2019-05-17T23:06:54+01:00",
"last_expires_at": "2020-06-06T01:00:00+01:00",
"people": [
"alice"
]
},
{
"thing": "avengers",
"weight": 0.6666666666666667,
"last_actioned_at": "2019-05-17T23:06:54+01:00",
"last_expires_at": "2020-06-06T01:00:00+01:00",
"people": [
"bob"
]
}
],
"neighbourhood": {
"bob": 0.6666666666666667,
"alice": 1
},
"confidence": 0.002462038997842016
}
How can I create an indexe array called results
whose values is the values for all the thing
properties.
As such:
['spiderman','xmen','barbie','avengers']
But if I try:
let results = results_.map(a => a.thing);
I get
Unhandled rejection TypeError: expecting an array, a promise or a thenable
......................................................................................................................................................................................................................................................................................................................
My question is different from From an array of objects, extract value of a property as array because that requires the array to be a typed in variable so the answers given do not work for me.I have gotten the solution now so pls unmark my post so I can post the solution.