response-json
v1.0.1
Published
Attempts to get a json object back from an xhr object.
Downloads
5
Readme
response-json
Attempts to get a json object back from an xhr object.
Install
$ npm install response-json
Usage
var $ = require('jquery');
var responseJSON = require('response-json');
$.ajax({
// generates 500 server error and returns '{"body": "Oops, something went wrong. :("}'
url: 'http://example.com/get-some-json',
error: function (xhr) {
var msg = responseJSON(xhr);
console.log(msg.body); // output: Oops, something went wrong. :(
}
});
Test
$ npm test
License
MIT © Purpose Industries