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
1 changed files with 2 additions and 2 deletions

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');