Skip to content

Commit

Permalink
Update requestHandler.js
Browse files Browse the repository at this point in the history
wrapped JSON.parse in try/catch
  • Loading branch information
noeplease authored Apr 20, 2020
1 parent 1319887 commit d715dc1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/middlewares/requestHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ let request = function (options) {
});
httpres.on('end', function () {
console.log("Requested: ", options.path, "\n : ", str);
let result = JSON.parse(str);
let result;
try{
result = JSON.parse(str);
}catch (e) {
return reject(e)
}
if(result.s !== 'ok'){
return reject(result)
}
Expand Down

0 comments on commit d715dc1

Please sign in to comment.