2 constructor(options = {}) {
3 this._baseURL = options.baseURL || "";
6 async _fetchJSON(endpoint, headers = {}, options = {}) {
7 const res = await fetch(this._baseURL + endpoint, {
12 if (!res.ok) throw new Error(res.statusText);
14 if (options.parseResponse !== false && res.status !== 204)
22 return this._fetchJSON(params.endpoint, params.headers, {
29 return this._fetchJSON(params.endpoint, params.headers, {
31 body: params.body ? JSON.stringify(params.body) : undefined,
37 return this._fetchJSON(params.endpoint, params.headers, {
39 body: params.body ? JSON.stringify(params.body) : undefined,
45 return this._fetchJSON(params.endpoint, params.headers, {
52 //TODO: Implement count method
54 getDefaultJSONPayloadHeader() {
55 return { "Content-Type": "application/json;charset=utf-8" };
59 export default HttpClient;