Add convenience methods for HTTP requests
Issue #12
resolved
Currently we use constructs like this:
dependencies.request(options, function(err, response, blockerJSON) {
if (err || !response || response.statusCode != 200) {
var error_msg = (err || (response ? ("bad statusCode: " + response.statusCode) : "bad response")) + " from " + options.url;
logger.error(error_msg);
callback(error_msg);
} else {
var data;
try {
data = JSON.parse(blockerJSON);
}
catch (e){
return callback(err);
}
callback(null, {issues: data.issues});
}
});
We could easily extract the error handling and provide methods like requestJSON().
Comments (2)
-
-
- changed status to resolved
Introduced two convenient methods (JSON and HTML) under the new easyRequest dependency. With tests.
- Log in to comment
now that we have job dependency injection, this should be easy to implement (work need to be done on lib/job-dependencies/request)