]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/http.js
Quick run through of applying new test entity helper class
[bookstack] / resources / js / services / http.js
index 8ecd6c109168d26a48024c3dbb847b130e3d1592..00865e69bd8ff83698864ed7c6d0dd0042ef465f 100644 (file)
@@ -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<Object|String>}
  */
 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();