| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x 1x | var Api = require('./Api')
class ApiTask {
constructor(opts, config, logger) {
this.opts = opts
this.logger = logger
this.api = new Api(config)
this.method = opts.method
this.route = opts.route
this.query = opts.query
}
run(cb) {
this.api.makeRequest(this.method, this.route, this.query, (err, body) => {
if (err) {
cb(err);
} else {
console.log(JSON.stringify(body, null, 2));
cb(null, body);
}
})
}
}
module.exports = ApiTask
|