@request/api
Use this module to create sugar API for your HTTP client. You can also allow your users to define their own method aliases.
var api = require('@request/api')
var client = require('@request/client')
var config = {
method: {
get: ['select']
},
option: {
qs: ['where'],
callback: ['done']
},
custom: {
check: [],
submit: ['gimme']
}
}
var custom = {
check: function (options, host) {
if (/localhost/.test(host)) {
options.url += ':6767'
}
return this
},
submit: function (options) {
return client(options)
}
}
var request = api(config, custom)
request
.select('http://localhost')
.check('localhost')
.where({a: 'b'})
.done((err, res, body) => {
})
.gimme()
See @request/core for more details.