From d715dc1c993069c5366940de524a3aef73ab08c7 Mon Sep 17 00:00:00 2001 From: Noe Date: Mon, 20 Apr 2020 15:08:13 -0700 Subject: [PATCH] Update requestHandler.js wrapped JSON.parse in try/catch --- app/middlewares/requestHandler.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/middlewares/requestHandler.js b/app/middlewares/requestHandler.js index 8e35be7..fd6b15e 100644 --- a/app/middlewares/requestHandler.js +++ b/app/middlewares/requestHandler.js @@ -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) }