@hashrytech/quick-components-kit 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/modules/api-client.js +6 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -97,7 +97,7 @@ export class ApiClient {
|
|
|
97
97
|
* @returns A processed `Request` object ready for `fetch`.
|
|
98
98
|
*/
|
|
99
99
|
async processRequest(endpoint, method, body, options) {
|
|
100
|
-
const url = new URL(endpoint, this.baseURL); // Resolve endpoint relative to baseURL
|
|
100
|
+
const url = this.baseURL ? new URL(endpoint, this.baseURL).toString() : endpoint; // Resolve endpoint relative to baseURL
|
|
101
101
|
const requestHeaders = new Headers(this.defaultHeaders);
|
|
102
102
|
// Merge custom headers from options using Headers constructor for robustness
|
|
103
103
|
if (options.headers) {
|
|
@@ -133,7 +133,7 @@ export class ApiClient {
|
|
|
133
133
|
processedBody = body;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
-
let request = new Request(url
|
|
136
|
+
let request = new Request(url, {
|
|
137
137
|
method: method,
|
|
138
138
|
headers: requestHeaders,
|
|
139
139
|
body: processedBody,
|
|
@@ -176,11 +176,11 @@ export class ApiClient {
|
|
|
176
176
|
}
|
|
177
177
|
switch (options.responseType) {
|
|
178
178
|
case 'text':
|
|
179
|
-
return
|
|
179
|
+
return await response.text();
|
|
180
180
|
case 'blob':
|
|
181
|
-
return
|
|
181
|
+
return await response.blob();
|
|
182
182
|
case 'arrayBuffer':
|
|
183
|
-
return
|
|
183
|
+
return await response.arrayBuffer();
|
|
184
184
|
case 'raw': return response;
|
|
185
185
|
case 'json':
|
|
186
186
|
default:
|
|
@@ -189,7 +189,7 @@ export class ApiClient {
|
|
|
189
189
|
return {}; // Return an empty object for no content
|
|
190
190
|
}
|
|
191
191
|
try {
|
|
192
|
-
return
|
|
192
|
+
return await response.json();
|
|
193
193
|
}
|
|
194
194
|
catch {
|
|
195
195
|
throw new Error('Failed to parse response as JSON. Response was OK, but not valid JSON.');
|