I have an object which has some values like "1", "5", "6" etc and refers to "data1", "data2", "data3" etc as an object.
I am trying to map this object but it is not mapping and looking for id. Here is the object that I am talking about:
[
{
"1": "data1",
"5": "data2",
"6": "data3"
}
]
And here is the object that I need:
[
{
id: "0",
ids: "1",
data: "data1"
},
{
id: "1",
ids: "5",
data: "data2"
},
{
id: "2",
ids: "6",
data: "data3"
},
}
]
Is there a way to solve this automatically from the response by JavaScript?
I have this response in my React app and specifically using Refine framework(refine.dev) and when I try to map this response, it is looking for reference. I tried every possible answer here: map function for objects (instead of arrays) but has no luck for my case.