diff --git a/addon/mixins/adapter-fetch.js b/addon/mixins/adapter-fetch.js index 26ed05da..3e2365cf 100644 --- a/addon/mixins/adapter-fetch.js +++ b/addon/mixins/adapter-fetch.js @@ -130,7 +130,9 @@ export default Ember.Mixin.create({ }) .then((response) => { if (response.ok) { - const bodyPromise = response.json(); + // We want to check that there is a body in the response, otherwise JSON.parse will throw an error. + // Instead, we'll let Ember Data handle an empty response. + const bodyPromise = response.headers.get('content-length') ? response.json() : {}; return this.ajaxSuccess(response, bodyPromise, requestData); } throw this.ajaxError(null, response, requestData);