ajax-request — Simplified http request
var request = ;
install
npm install ajax-request --save
test
mocha
API
request(options, callback)
- {obejct|string}
options
required
If the options is string, it will send get request.- {string}
options.url
required - {string}
options.method
[options.method=GET]
The http request type - {obejct}
options.data
if the request type isGET
, it's appended to query string of the URL, or it's sended to remote of body. - {object}
options.headers
An object containing request headers. - {string}
options.encoding
Set response data encoding - {boolean}
options.isBuffer
[options.isBuffer=false]
Parse response data to buffer - {boolean}
options.json
[options.json=false]
Parse response data to json
- {string}
- {function}
callback
required
; ;
.post(options, callback)
The API same as request
request;
.download(options, callback)
- {obejct}
options
requiredoptions.url
{string} requiredoptions.ignore
{boolean} [options.ignore=false]
Is the filepath ignore case.options.rootPath
{string} [options.rootPath='']
The root of dest pathoptions.destPath
{string|function}
Custom the download path.
- {function}
callback
required
request; request;
.base64(url, callback)
Deprecated, move to base64