Skip to content

Instantly share code, notes, and snippets.

@bhuizi
Created June 27, 2017 00:01
Show Gist options
  • Save bhuizi/b2ef4a0e977494b61307af0719f7fae3 to your computer and use it in GitHub Desktop.
Save bhuizi/b2ef4a0e977494b61307af0719f7fae3 to your computer and use it in GitHub Desktop.
post request: using request
// superagent example https://github.com/request/request#streaming
const request = require('request');
const obj = {
username: 'string',
password: 'string',
redirectUrl: 'string',
sso: 'string'
};
// example 1
request.post(url, {form: obj}, (err, httpResponse, body) => {
console.log(httpResponse.headers);
});
// example 2
request.post(url, {form: obj})
.on('response', (res) => {
console.log(res.headers);
})
.on('error', (err) => {
console.log(err);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment