Skip to content

2.7.0

Compare
Choose a tag to compare
@floatdrop floatdrop released this 06 Apr 11:34

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
});

v2.6.0...v2.7.0