Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda