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

233
Visualizações
Why i cannot get a JSON response data in Javascript? with axios+express

I'm trying to get the lyrics as a response to this simple lyrics request (of an Eminem song for example) , it doesn't give me any errors but I don't understand why I'm not getting the response. What am i missing? Please help me :)

app.get('/lyrics', function(req, res)
{
  axios.get('https://api.lyrics.ovh/v1/eminem/stan')
    .then(function(data)
    {
      let result = {
        lyrics : data['lyrics'],
      };
      res.status(200).send(result);
    })
    .catch(function(err)
    {
      if(err['statusCode'] == 404)
        res.send({error : {status : 404, message : 'Lyrics not found'}});
      else
        res.send(err);
    })
    .then(function () {
    // always executed
    });
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As Phil Mentioned, Edit your code to this and you'll be fine

app.get('/lyrics', function(req, res)
{
  axios.get('https://api.lyrics.ovh/v1/eminem/stan')
    .then(function(data)
    {
      let result = {
        lyrics : data.data.lyrics,
      };
      res.status(200).send(result);
    })
    .catch(function(err)
    {
      if(err['statusCode'] == 404)
        res.send({error : {status : 404, message : 'Lyrics not found'}});
      else
        res.send(err);
    })
    .then(function () {
    
    });
});
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