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

400
Views
Simple API call with "Bearer" token Authorization using Ajax

My problem is that I couldn't fetch data from API using Ajax.

I'm using a JWT token for authentication and when I call the API from Postman, I get the data successfully.

enter image description here

However, when calling the API using ajax, an ERR_ABORTED 401 (Unauthorized) error is detected. Here's the code:

$.ajax({
    type: "GET",
    url: API_URL,
    dataType: 'jsonp',
    contentType: "application/json",
    headers: {
        "Cache-Control": "no-cache",
        "Authorization": "Bearer " + access_token,
    },
    data: {}, 
    success: function(resp){
        console.log(resp)
    }, 
    error: function(error){
    }    
})

Also, I get the same error when I copy and use the code snippet generated by POSTMAN.

enter image description here

I've searched a lot of answers for this and applied them, but it doesn't work for me.

Can someone help with this?

Thank you in advance.

over 4 years ago · Santiago Trujillo
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!