I am trying to convert an array that contains objects into a single object where the key is "page" and the value is "has_access". So I could access it later with has_access.about for example.
Is there a single one line of code that could achieve this?
I tried this but it is giving me back the original array.
var myData = Object.keys(data).map(key => {
return data[key];
})
Here is the source array that I would like to convert
[
{
"id": 215,
"page": "home",
"has_access": 1,
},
{
"id": 216,
"page": "about",
"has_access": 0,
},
{
"id": 217,
"page": "profile",
"has_access": 1,
}
]
Desired result:
has_access: {
home: 1
about: 0
profile: 1
}