1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +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,
// fetch will resolve responseText to the string 'None'.
// If this is the case, we can not try to parse it as JSON.
if(responseText !== 'None') {
let body = JSON.parse(responseText);
if (responseText && responseText !== 'None') {
const body = JSON.parse(responseText);
if(body && body.errors) {
let error = new Error('Form Error');