Skip to content

Commit a6b9192

Browse files
committed
Fix bug when json is not valid
1 parent 9eb2274 commit a6b9192

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Query.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@
9090
}
9191

9292
if (valid) {
93-
resolve(JSON.parse(body))
93+
try {
94+
let object = JSON.parse(body)
95+
resolve(object)
96+
} catch (e) {
97+
console.log(e)
98+
resolve({success: false, type: 'error', message: 'JSON error', data: [], length: 0})
99+
}
94100
} else {
95101
resolve({success: false, type: 'error', message: 'Invalid data from server', data: [], length: 0})
96102
}

0 commit comments

Comments
 (0)