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

155
Views
¿Cómo obtener los datos clave específicos de una matriz multidimensional en reaccionar?

Estoy trabajando con una API donde obtuve datos en este formato: -

 [ 0:{ id: "1" name: "ttp" platforms:{ one: "false", } }, 1:{ id: "2" name: "spt" platforms:{ one: "true", two: "true", } }, }, ]

Los datos son muy grandes, tiene más de 100 índices. Quiero verificar si las plataformas están presentes en el índice. Supongamos que si algún índice contiene la plataforma one , quiero mostrar su id y no quiero mostrar ese índice que no tiene la plataforma one . Pero sé cómo hacer esto en React.

Aquí el código que quiero cambiar, no quiero usar el índice [0]

 if (response.status === 200) { console.log(response.data) list = response.data[0].platforms; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede usar filter() para filtrar su matriz y obtener solo los elementos que necesita según una condición.

En tu caso :

 if (response.status === 200) { console.log(response.data) list = response.data; const filteredList = list.filter( (e: any) => (e.platforms.one)); // filteredList contains just the objects that contains the value one }
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!