]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Check if path has data before adding / 393/head
authorJames White <james@jmwhite.co.uk>
Sat, 5 Mar 2022 18:13:43 +0000 (18:13 +0000)
committerJames White <james@jmwhite.co.uk>
Sun, 6 Mar 2022 20:04:16 +0000 (20:04 +0000)
src/mixins/service.js

index 17fa6fcc95600f955a55014d878285f1a7c45a4f..abc708c9d326549aa74ab4ac330e92bd49f3ca3e 100644 (file)
@@ -31,7 +31,13 @@ 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");
         }