@@ -, +, @@ --- .../intranet-tmpl/prog/js/vue/fetch/erm-api-client.js | 5 +---- .../intranet-tmpl/prog/js/vue/fetch/http-client.js | 10 ++++------ 2 files changed, 5 insertions(+), 10 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js +++ a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js @@ -24,23 +24,20 @@ export class ERMAPIClient extends HttpClient { delete: (id) => this.delete({ endpoint: "agreements/" + id, - headers: this.getDefaultJSONPayloadHeader(), }), create: (agreement) => this.post({ endpoint: "agreements", body: agreement, - headers: this.getDefaultJSONPayloadHeader(), }), update: (agreement, id) => this.put({ endpoint: "agreements/" + id, body: agreement, - headers: this.getDefaultJSONPayloadHeader(), }), //count: () => this.count("agreements"), //TODO: Implement count method }; } } -export default ERMAPIClient; +export default ERMAPIClient; --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js +++ a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js @@ -1,12 +1,15 @@ class HttpClient { constructor(options = {}) { this._baseURL = options.baseURL || ""; + this._headers = options.headers || { + "Content-Type": "application/json;charset=utf-8", + }; } async _fetchJSON(endpoint, headers = {}, options = {}) { const res = await fetch(this._baseURL + endpoint, { ...options, - headers: headers, + headers: { ...this._headers, ...headers }, }); if (!res.ok) throw new Error(res.statusText); @@ -18,7 +21,6 @@ class HttpClient { } get(params = {}) { - console.log(params); return this._fetchJSON(params.endpoint, params.headers, { ...params.options, method: "GET", @@ -50,10 +52,6 @@ class HttpClient { } //TODO: Implement count method - - getDefaultJSONPayloadHeader() { - return { "Content-Type": "application/json;charset=utf-8" }; - } } export default HttpClient; --