]> git.immae.eu Git - github/bastienwirtz/homer.git/blobdiff - src/mixins/service.js
Initial Emby service commit
[github/bastienwirtz/homer.git] / src / mixins / service.js
index ae23a2742bc5130fc4f08b9a16ab92192afa3f85..abc708c9d326549aa74ab4ac330e92bd49f3ca3e 100644 (file)
@@ -12,7 +12,7 @@ export default {
     }
   },
   methods: {
-    fetch: function (path, init) {
+    fetch: function (path, init, json = true) {
       let options = {};
 
       if (this.proxy?.useCredentials) {
@@ -31,11 +31,18 @@ export default {
         path = path.slice(1);
       }
 
-      return fetch(`${this.endpoint}/${path}`, options).then((response) => {
+      let url = this.endpoint;
+
+      if (path) {
+        url = `${this.endpoint}/${path}`;
+      }
+
+      return fetch(url, options).then((response) => {
         if (!response.ok) {
           throw new Error("Not 2xx response");
         }
-        return response.json();
+
+        return json ? response.json() : response;
       });
     },
   },