Created
June 27, 2017 00:01
-
-
Save bhuizi/b2ef4a0e977494b61307af0719f7fae3 to your computer and use it in GitHub Desktop.
post request: using request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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