Skip to content

Instantly share code, notes, and snippets.

@rluena
Last active February 21, 2019 20:53
Show Gist options
  • Save rluena/8bf237b95449ac7d0a367d41b385f030 to your computer and use it in GitHub Desktop.
Save rluena/8bf237b95449ac7d0a367d41b385f030 to your computer and use it in GitHub Desktop.
Sending form data using chai-http
// Sending form data
chai = require('chai');
chaiHttp = require('chai-http')
chai.use(chaiHttp);
stripe_request = chai.request('https://api.stripe.com');
stripe_request.post('/v1/tokens')
.set('content-type', 'application/x-www-form-urlencoded')
.send({
card:{
name: test_user.name,
number: '4242 4242 4242 4242',
cvc: 555,
exp_month: 08,
exp_year: 2018
},
key: stripe_pk_local_key
})
.end(function(err, res) {
console.log(err);
console.log(res.body);
// You can continue with your test here
done();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment