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

737
Visualizações
My GET request works fine in POSTMAN and Curl, but not in JavaScript code

When I make my get request with POSTMAN or Curl, it works just fine and I get the expected response. I just set type to GET, insert my URL and insert a key named token/email and set it to a token/email I get from another service. But when I try to call the same service in code like this:

   function getAll() {
        const myHeaders = new Headers({
            'Accept': 'application/json',
            'token': 'MY TOKEN',
            'email': 'MY EMAIL'
        });


        return fetch('https://apitul', {
            headers: myHeaders,
            method: 'GET'
        })
        
        .then(response => {
            if (response.status === 200) {
            return response.json();
            } else {
            throw new Error('Something went wrong on api server!');
            }
        })
        .then(response => {
            console.debug(response);
        }).catch(error => {
            console.error(error);
        });
    }

I get 401 error. I also found out that the server is not receiving the token in the request header. Any ideas how I can fix this? Cheers.

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

0

To send your token in header use this: 'Authorization': 'Bearer yourToken'

about 4 years ago · Juan Pablo Isaza Relatório

0

Try to generate code using Postman, lets see if it helps. See attached.

Try to generate code using Postman, let's see if it helps. See attached.

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