X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/7590ecd37c49b12fb6cf2ad251b1e65c1ea7d1ee..refs/pull/2700/head:/resources/js/services/http.js diff --git a/resources/js/services/http.js b/resources/js/services/http.js index 8ecd6c109..00865e69b 100644 --- a/resources/js/services/http.js +++ b/resources/js/services/http.js @@ -141,12 +141,16 @@ async function request(url, options = {}) { /** * Get the content from a fetch response. * Checks the content-type header to determine the format. - * @param response + * @param {Response} response * @returns {Promise} */ async function getResponseContent(response) { - const responseContentType = response.headers.get('Content-Type'); - const subType = responseContentType.split('/').pop(); + if (response.status === 204) { + return null; + } + + const responseContentType = response.headers.get('Content-Type') || ''; + const subType = responseContentType.split(';')[0].split('/').pop(); if (subType === 'javascript' || subType === 'json') { return await response.json();