1.0.0 • Published 11 years ago
request-sync v1.0.0
request-sync is deprecated, use sync-request
request-sync
Because sometimes you want your web requests to be synchronous
Installation
npm install request-syncUsage
Make a web request:
Options:
uri||url- fully qualified uri or parsed url object fromurl.parse()method- http method (default:"GET")qs- object containing querystring values to be appended to theuriheaders- http headers (default:{})body- entity body for PATCH, POST and PUT requests. Must be aBufferorString.auth- A hash containing valuesuser||username,password||passencoding- encoding to stringify the result body, set this tonullto get aBuffer
var response = request('http://www.example.com');
// => {statusCode: 200, headers: {}, body: 'string of html'}
var response = request('http://www.example.com', {method: 'GET'});
// => {statusCode: 200, headers: {}, body: 'string of html'}
var response = request({method: 'GET', uri: 'http://www.example.com'});
// => {statusCode: 200, headers: {}, body: 'string of html'}License
MIT