@dexyn/common-library 1.1.4 → 1.1.5
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/api/apiClientUtils.js +3 -2
- package/package.json +1 -1
package/api/apiClientUtils.js
CHANGED
@@ -50,14 +50,15 @@ const createApiClient = (basePath, debugMode = false) => {
|
|
50
50
|
logger_1.logger.log(`Response status: ${response.status}`, debugMode);
|
51
51
|
logger_1.logger.log(`Response headers: ${JSON.stringify(Object.fromEntries(response.headers.entries()))}`, debugMode);
|
52
52
|
logger_1.logger.log(`Response URL: ${response.url}`, debugMode);
|
53
|
-
logger_1.logger.log(`Response body: ${await response.text()}`, debugMode);
|
54
53
|
if (!response.ok) {
|
55
54
|
const errorData = await response.json();
|
56
55
|
return errorData;
|
57
56
|
}
|
58
57
|
// Handle no content for 202 or other no-body status codes
|
59
58
|
if (response.status === 202 || response.status === 204 || !response.headers.get('Content-Type')) {
|
60
|
-
const body = await response.json().catch(() =>
|
59
|
+
const body = await response.json().catch((e) => {
|
60
|
+
logger_1.logger.log(`Response body: ${JSON.stringify(e)}`, debugMode);
|
61
|
+
}); // Safely attempt to parse body
|
61
62
|
// Check if body is not an empty object
|
62
63
|
if (body && Object.keys(body).length > 0) {
|
63
64
|
return body;
|