Skip to content

Instantly share code, notes, and snippets.

@ragog
Created April 9, 2021 13:06
Show Gist options
  • Save ragog/cd951d02ff2fea3b9f4de86a9c6a4273 to your computer and use it in GitHub Desktop.
Save ragog/cd951d02ff2fea3b9f4de86a9c6a4273 to your computer and use it in GitHub Desktop.
const { default: axios } = require("axios");
const expect = require('expect')
const AUTH_TOKEN = Buffer.from(process.env.API_KEY).toString('base64')
axios({
method: 'get',
url: 'https://api.stripe.com/v1/customers',
headers: {
'Authorization': `Basic ${AUTH_TOKEN}`,
'content-type': 'application/x-www-form-urlencoded'
},
data: 'limit=3'
}).then((response)=> {
console.log(response.data)
expect(response.status).toBe(200) // 1) assert again status code
expect(response.headers['content-type']).toBe('application/json') // 2) assert against header
expect(response.data['has_more']).toBe(true) // 3) assert against body
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment