Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

729
Vistas
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 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda