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

341
Views
Getting no authorization header value error,

Authorization Headers (bearer token) not getting adding into the api calls
Status is 401 Unautorized and headers are not getting added into the api call.

  const axios = require('axios')
    
    let token = 'eyJ0eXAiOiJOiJIUzI1NiJ9.eyJpc3MiOiJJQ00iLCJhdWQiOiJzZXNzaW9uLW1hbm'
    export class classname )
        async getReports ()
        {
            let response
            try {
                response = await axios.get(`https://urltogo/path`), {
                    headers: {
                        'Content-Type' : 'application/json',
                        Authorization : `Bearer ${token}`                   
                    }
                }
                const responseObj = {
                    url: `GET ${`https://urltogo/path`}`,
                    status: response.status,
                    data: response.data
                }
                if (responseObj.data.meta.count == 1) {
                    return responseObj.data.items[0].id
                }
            } catch (error) {
                const errorObj = {
                    status: error.response?.status,
                    data: error.response?.data
                }
                throw new Error(JSON.stringify(errorObj))
            }
        }  
    }

Getting Error

"status":401,"data":{"message":"Unauthorized, **no authorization header value**"}}

data: error.response?.data

not sure what i am missing here in the code
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You need to put the options as second argument of the get method, not after closing it.

response = await axios.get(`https://urltogo/path`, {
  headers: {
    'Content-Type' : 'application/json',
    Authorization : `Bearer ${token}`                   
  }
});
about 4 years ago · Juan Pablo Isaza Report

0

Updated the @reyno answer with bold

 response = await axios.get**(**`https://urltogo/path`,{
                    headers: {
                        'Content-Type' : 'application/json',
                        'Authorization' : `Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ`}
                } **)**;
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!