Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
how to get the specific key data from multidimensional array in react?

I am working with an API where I got data in this format:-

[
  0:{
    id: "1"
    name: "ttp"
    platforms:{
       one: "false",
    }
  },

 1:{
    id: "2"
    name: "spt"
    platforms:{
       one: "true",
       two: "true",
    }
  },
},
]

The data is very large it has more than 100 indexes. I want to check if platforms are present in the index. Suppose if any index contains platform one I want to show its id and don't want to show that index that doesn't have platform one. But I am how to do this in React.

Here the code I want to change, Don't want to use the index [0]

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

0

You can use filter() to filter your array and get just the elements you need based on a condition.

In your case :

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda