Check if path has data before adding /

This commit is contained in:
James White 2022-03-05 18:13:43 +00:00
parent ba2c7c5c57
commit 1340a8e6d0

View 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");
}