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

231
Views
Passing Authorization in Axios Header Not Working

I am trying to dynamically generate checkout on the Coinbase Commerce API. I am following the documentation found here and porting into a javascript website using axios to make requests.

It seems like their setup requires authentication to be passed in the header of the requests, which I am doing but for some reason it is not working correctly. Their example works in curl directly on terminal, but something appears to be busted in my axios code. Could you kindly let me know how I can fix this?

Working Curl Request

curl https://api.commerce.coinbase.com/checkouts \
     -X POST \
     -H 'Content-Type: application/json' \
     -H "X-CC-Api-Key: <Your API Key>" \
     -H "X-CC-Version: 2018-03-22" \
     -d '{
         "name": "The Sovereign Individual",
         "description": "Mastering the Transition to the Information Age",
         "local_price": {
             "amount": "100.00",
             "currency": "USD"
         },
       "pricing_type": "fixed_price",
         "requested_info": ["email"]
     }'

Javascript / Axios Script

let amount = 10;
try {

    let options = {
        headers: {
            "Content-Type": "application/json",
            "x-api-key": "<Your API Key>",
            "X-CC-Version": "2018-03-22"
        }
    }

    let data = {
        "name": "US$" + amount + " Credit Refill",
        "description": "Credit refill",
        "local_price": {
            "amount": amount,
            "currency": "USD"
        },
        "pricing_type": "fixed_price"
    };

    let response = await axios.post('https://api.commerce.coinbase.com/checkouts', data, options);
    console.log(response.data);

} catch (error) {
    console.log(error)
}

Error

Error 401 / authorization_error

about 4 years ago · Juan Pablo Isaza
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!