request-sync-win
v0.0.2
Published
Because sometimes you want your web requests to be synchronous
Downloads
33
Readme
此插件从request-sync插件修改而来,去掉了调用http-sync扩展的部分。以下为原插件的说明。
request-sync
Because sometimes you want your web requests to be synchronous
Installation
npm install request-sync
Usage
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 theuri
headers
- http headers (default:{}
)body
- entity body for PATCH, POST and PUT requests. Must be aBuffer
orString
.auth
- A hash containing valuesuser
||username
,password
||pass
encoding
- encoding to stringify the result body, set this tonull
to 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