I'm working with an array from an api call, which I would like to rearrange for something else.
payload = [
{
"id": rexiy,
"orderLabel": "PREP",
"balance": 1900,
"virtual": false,
"type": "credit",
},
{
"id": erptq,
"orderLabel": "PREP",
"balance": 500,
"virtual": true,
"type": "debit"
}
]
I'm trying to create a new array that would have this format
array = [
{
rexiy:1900
},
{
erptq:500
}
]
How do I go about it
payload.map(elm => { return {[elm.id]: elm.balance } })