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

167
Visualizações
Axios get request from url

So I'm having an issue with the npm package axios when trying to make a get request to a URL. I get an error code 503 every time; this is my code:

let data, response;

response = await axios.get(url, {
    headers: {
        Accept: 'application/json',
    }
})

So at first, I thought I did something wrong with the code (like changing Accept to 'Accept'), but when I do the exact same thing on Postman, it returns just fine.

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

So I tried by changing the User-Agent option in the headers to the one from Postman, and now it just seems to be working.

let data, response;

response = await axios.get(url, {
    headers: {
        'Accept': 'application/json',
        'User-Agent': 'PostmanRuntime/7.28.4',
    }
});

I'm still a bit new to http requests, so I really don't understand how this happens. I'm using axios in other cases with different URL's too and there everything just runs fine.

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