]>
git.immae.eu Git - github/bastienwirtz/homer.git/blob - src/mixins/service.js
6 // custom service often consume info from an API using the item link (url) as a base url,
7 // but sometimes the base url is different. An optional alternative URL can be provided with the "endpoint" key.
8 this.endpoint
= this.item
.endpoint
|| this.item
.url
;
11 fetch: function (path
, init
) {
14 if (this.proxy
?.useCredentials
) {
15 options
.credentials
= "include";
18 options
= Object
.assign(options
, init
);
20 return fetch(`${this.endpoint}/${path}`, options
).then((response
) => {
22 throw new Error("Not 2xx response");
24 return response
.json();