1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Fix "Unexpected end of input" JSON parse exceptions

This commit is contained in:
Brett Sun 2016-03-10 12:11:45 +01:00
parent 5e6b483149
commit 30ba85d937

View File

@ -39,8 +39,8 @@ class Requests {
// If the responses' body does not contain any data, // If the responses' body does not contain any data,
// fetch will resolve responseText to the string 'None'. // fetch will resolve responseText to the string 'None'.
// If this is the case, we can not try to parse it as JSON. // If this is the case, we can not try to parse it as JSON.
if(responseText !== 'None') { if (responseText && responseText !== 'None') {
let body = JSON.parse(responseText); const body = JSON.parse(responseText);
if(body && body.errors) { if(body && body.errors) {
let error = new Error('Form Error'); let error = new Error('Form Error');