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

183
Visualizações
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 Respostas
Responde à pergunta

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 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