Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
Problem mapping over data from API as its just an object not an array of objects in React

If I have this data structure coming from an api:

{
  "value": 0,
  "time": [
    "2021-10-15"
  ],
  "innerArray": [
    {
      "name": "string",
      "Value": [
        0
      ]
    }
  ]
}

I am trying to access the element by:

let dataLoop = data // object from api

then I am doing:

   function Loop() {
        dataLoop.map((inner: any) => {
            console.log('series =', inner.innerArray);
        })
    };

But I am getting TypeError: dataLoop.map is not a function

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is because

{
  "value": 0,
  "time": [
    "2021-10-15"
  ],
  "innerArray": [
    {
      "name": "string",
      "Value": [
        0
      ]
    }
  ]
}

is an object, you can map only on Array type elements.

innerArray is an element on which you can .map like this:

    dataLoop.innerArray.map((inner: any) => {
        console.log('series =', inner);
    })

to be able to map through an object you have to use Object like:

Object.entries(data).map(([key,value])=>{
  console.log(key,value)
})

for example, so output would be like :

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!