diff --git a/lib/event/EventsAdapter.js b/lib/event/EventsAdapter.js index aea02e7..fd3e53b 100644 --- a/lib/event/EventsAdapter.js +++ b/lib/event/EventsAdapter.js @@ -262,7 +262,13 @@ var EventsAdapter = function EventsAdapter() { //console.log('get events from ' + url); fetch(url) - .then((response) => response.json()) + .then((response) => { + if (response.headers.get('content-type') === 'application/json') { + return response.json(); + } + + throw new TypeError(); + }) .catch((error) => { console.error(error); return callback(error, []); diff --git a/lib/festival/FestivalsAdapter.js b/lib/festival/FestivalsAdapter.js index 5c1236d..5f36b28 100644 --- a/lib/festival/FestivalsAdapter.js +++ b/lib/festival/FestivalsAdapter.js @@ -205,7 +205,13 @@ var FestivalsAdapter = function FestivalsAdapter() { var fetchFestivals = function fetchFestivals(callback) { fetch(API_URL + FESTIVALS_RESOURCE_NAME + FESTIVALS_QUERY) - .then((response) => response.json()) + .then((response) => { + if (response.headers.get('content-type') === 'application/json') { + return response.json(); + } + + throw new TypeError(); + }) .catch((error) => { console.error(error); return callback(error, []);