1.3.1 • Published 5 years ago
@gosuite/ajax-request-fork v1.3.1
ajax-request — Simplified http request
var request = require('ajax-request');install
npm install ajax-request --savetest
mochaAPI
request(options, callback)
- {obejct|string}
optionsrequired
If the options is string, it will send get request.- {string}
options.urlrequired - {string}
options.methodoptions.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.isBufferoptions.isBuffer=false
Parse response data to buffer - {boolean}
options.jsonoptions.json=false
Parse response data to json
- {string}
- {function}
callbackrequired
request('url', function(err, res, body) {});
request({
url: '',
method: 'GET',
data: {
query1: 'value1'
}
}, function(err, res, body) {
});.post(options, callback)
The API same as request
request.post({
url: 'url',
data: {},
headers: {}
});.download(options, callback)
- {obejct}
optionsrequiredoptions.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}
callbackrequired
request.download({
url: 'path/index.png',
rootPath: ''
}, function(err, res, body, destpath) {});
request.download({
url: 'path/index.png',
destPath: function(filename) {
return filename;
}
}, function(err, res, body, destpath) { });.base64(url, callback)
Deprecated, move to base64
1.3.1
5 years ago
