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

154
Vistas
how to authenticate http request in axios

I am using Axios on a node mjs script. I am hitting a server that uses basic http authentication. on browser, if I hit

http://user:pass@192.168.254.4/api/endpoint1

it works and gives me the requested data but when I use the same URL on Axios.get method it fails.

Unauthorized

This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to give the credentials required.

same thing on postman too (doesn't work on postman either).

am I missing something here?

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

0

Here is the code:

var session_url = 'http://api_address/api/session_endpoint';
var username = 'user'; var password = 'password';
var credentials = btoa(username + ':' + password);
var basicAuth = 'Basic ' + credentials;
axios.post(session_url, { headers: { 'Authorization': + basicAuth } })
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