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

166
Visualizações
Call a specific array in a JSON API call

I'm trying to call the API but it doesn't return me anything. I'm calling it like: res.on('data', d => { const RetrieveFromApi = JSON.parse(d).FLUX.quote.USD.price;.

The API is successfully called since I can see it in the API history, and data is defined as d.

API Call

Can you help me please?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

from your screen provided in comment, you passed one property you don't access to it which is data So just add property data before FLUX

JSON.parse(d).FLUX.quote.USD.price;
             ^data.FLUX.quote.USD.price;
about 4 years ago · Juan Pablo Isaza Relatório

0

From the image of the log the object seems incomplete at the end, did you try to use JSON.stringify(d) to see if there are any errors on the json object? or copy the response on https://jsonlint.com to check?

Because the error message points that the parse doesn't find a valid json object, maybe that is the whole point.

And the other tip is to try to store the value of JSON.parse in an variable before trying to access his values.

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