Skip to content

Commit 7d9c3db

Browse files
Merge pull request #1 from ismailjfreaks/added-try-catch-block-on-JSON-parse-on-line-199
- added try-catch block on JSON.parse on line 199
2 parents 5731cbd + 0b7ed8d commit 7d9c3db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

IPGeolocationAPI.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,13 @@ function getRequest(subUrl, urlParams = '', callback) {
196196
'message': 'Internet is not connected!'
197197
};
198198
} else {
199-
jsonData = JSON.parse(this.responseText);
199+
try {
200+
jsonData = JSON.parse(this.responseText);
201+
} catch {
202+
jsonData = {
203+
'message': 'ipgeolocation.io seems to respond unexpectedly!'
204+
};
205+
}
200206
}
201207

202208
if (callback && typeof (callback) === typeof (Function)) {

0 commit comments

Comments
 (0)