2.7.0
New json
option for auto-parsing JSON response. abdd0f0
Before:
got('jsonendpoint.com', function (err, data) {
if (err) { return cb(err); }
var json;
try {
json = JSON.parse(data);
} catch (e) {
return cb(new Error('Reponse from jsonendpoint.com is broken: ' + e.message));
}
// working with json
});
After:
got('jsonendpoint.com', {json: true}, function (err, json) {
if (err) { return cb(err); }
// working with json
});