Skip to content

Commit

Permalink
Check for empty data before attempting JSON parsing on response
Browse files Browse the repository at this point in the history
  • Loading branch information
rossj committed Aug 26, 2013
1 parent 268274c commit c89e672
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/operation-factory.js
Expand Up @@ -117,7 +117,7 @@ var executeFactory = function (endpoint) {
f += ' res.on("readable", function() { data += res.read(); });\n';
f += ' res.on("end", function () {\n';
f += ' var error = (res.statusCode < 200 || res.statusCode >= 300) ? new Error("Status code " + res.statusCode) : null;\n';
f += ' cb(error, JSON.parse(data));\n';
f += ' cb(error, data && JSON.parse(data));\n';
f += ' });\n';
f += '});\n';

Expand Down

0 comments on commit c89e672

Please sign in to comment.