Merge pull request #393 from jamesmacwhite/ping-endpoint-urls

Check if path has data before adding a trailing slash (/)
This commit is contained in:
Bastien Wirtz 2022-03-06 22:30:10 +01:00 committed by GitHub
commit db2a2af3a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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