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

117
Visualizações
Parsed JSON data appearing as undefined in the console?

I used the fetch api to take the json data from the api that I linked in the code. I then tried to parse the data and log the quote from the parsed data in the console.

fetch("https://api.breakingbadquotes.xyz/v1/quotes")
.then(data => data.json())
.then(data => {
    console.log(JSON.parse(data.quote));
});

This came up with the error "unexpected token o in JSON at position 1" in the console, meaning that the data is already parsed. So, logically, I removed the JSON.parse method from line 4 expecting the issue to be resolved.

fetch("https://api.breakingbadquotes.xyz/v1/quotes")
.then(data => data.json())
.then(data => {
    console.log(data.quote);
});

However, this simply appeared as undefined in the console, meaning that data has not been parsed. Can anyone explain what the issue here is exactly? I apologize in advance if I am missing something obvious, I am still a beginner to javascript and programming as a whole. Thank you!

about 4 years ago · Santiago Gelvez
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