From 0b7ed8de8ea46151701b6012ee3391e860b0ba75 Mon Sep 17 00:00:00 2001 From: Ismail Jfreaks Date: Tue, 25 Oct 2022 16:03:52 +0500 Subject: [PATCH] - added try-catch block on JSON.parse on line 199 --- IPGeolocationAPI.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/IPGeolocationAPI.js b/IPGeolocationAPI.js index 05bef62..059261c 100755 --- a/IPGeolocationAPI.js +++ b/IPGeolocationAPI.js @@ -196,7 +196,13 @@ function getRequest(subUrl, urlParams = '', callback) { 'message': 'Internet is not connected!' }; } else { - jsonData = JSON.parse(this.responseText); + try { + jsonData = JSON.parse(this.responseText); + } catch { + jsonData = { + 'message': 'ipgeolocation.io seems to respond unexpectedly!' + }; + } } if (callback && typeof (callback) === typeof (Function)) {