Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
509 B
3
Indexable
Never
const key = 'chave secreta ...' // a chave fornecida pelo pagar.me
const corpoReq = { // o corpo de requisicao, se houver
    "obj1": "1234"
}


const response = await fetch('https://api.pagar.me/core/v5/orders', { // requisicao usando fetch
    method: 'POST',
    body: corpoReq,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Basic ' + new Buffer(`${key}`).toString('base64'),    }
  });
 
 const respJson = await response.json(); // converte a resposta da api para json