-1

I am fetching an API endpoint which returns data in the format

    {
      "0": {
      "name": "Rohan"
       },
      "1": {
      "name": "Meghan"
      },
      "2": {
      "name": "Rita"
      }
   }

But since it is not array my map function throws an error

Home.jsx:39 Uncaught TypeError: users.map is not a function

Hence I want to convert this object of objects into a const arrOfarr. The array should look like:

    [
      {
      "name": "Rohan"
      },
      {
      "name": "Meghan"
      },
      {
      "name": "Rita"
      }
   ]
Ele
  • 33,468
  • 7
  • 37
  • 75

1 Answers1

0

You can get key and value pairs with this line.

Object.entries(yourObj)

Ele
  • 33,468
  • 7
  • 37
  • 75
Shachar297
  • 599
  • 2
  • 7