Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

152
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!