From 1340a8e6d024ee0460a4fd3c218397251e2ac86b Mon Sep 17 00:00:00 2001 From: James White Date: Sat, 5 Mar 2022 18:13:43 +0000 Subject: [PATCH] Check if path has data before adding / --- src/mixins/service.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mixins/service.js b/src/mixins/service.js index 17fa6fc..abc708c 100644 --- a/src/mixins/service.js +++ b/src/mixins/service.js @@ -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"); }