Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda