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

180
Vistas
Post call not placing headers in call. Axios

I'm trying to do an Api Call, this is the code I'm using

axios.get("url", userData, {
        headers: {
            Authorization: "test"
        }
    }).then((response) => console.log(response, 'users/me'))
    .catch(err => console.log(err))

Its showing me the same error everytime

401 (Unauthorized)

And on the network on chrome dev tools, the Authorization is not appearing at all

Thanks a lot.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The Authorization reqest header has the following general scheme:

Authorization: <auth-scheme> <authorization-parameters>

Let us assume that your user id is john.smith and your password is password (don't do that).

Using the Basic authorization scheme, you take your user ID and password and join them with a colon:

john.smith:password

and then base-64 encyrpt that to get

am9obi5zbWl0aDpwYXNzd29yZA==

The Authorization header you need to pass then is

Authorization: Basic am9obi5zbWl0aDpwYXNzd29yZA==

Different schemes, of course, require different things in the header value.

Your 401 Unauthorized response status should have a WWW-Authenticate response header containing a list of 1 or more challenges telling you what authentication scheme(s) you may use.

Install Postman and fiddle with your API call until you get it working.

You can then export the API call as any of a number of different flavors of client-side code, Node.js - Axios being one of them.

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