@8ms/helpers 2.4.23 → 2.4.24
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/dist/api/deleteRequest.cjs +4 -1
- package/dist/api/deleteRequest.mjs +4 -1
- package/dist/api/get.cjs +4 -1
- package/dist/api/get.mjs +4 -1
- package/dist/api/post.cjs +7 -4
- package/dist/api/post.mjs +7 -4
- package/package.json +1 -1
|
@@ -15,7 +15,10 @@ const deleteRequest = async (url, config = {}) => {
|
|
|
15
15
|
throwHttpErrors: false,
|
|
16
16
|
...config
|
|
17
17
|
}).then(async (response) => {
|
|
18
|
-
const
|
|
18
|
+
const isJson = (response.headers.get("content-type") || "").includes("application/json");
|
|
19
|
+
let data;
|
|
20
|
+
if (isJson) data = await response.json();
|
|
21
|
+
else data = await response.text();
|
|
19
22
|
if (void 0 !== data.body && void 0 !== data.error && void 0 !== data.state) return new require_api_ApiResponseClass.ApiResponseClass(data);
|
|
20
23
|
else if (response.status >= 200 && response.status <= 299) return new require_api_ApiResponseClass.ApiResponseClass().setToSuccess(data);
|
|
21
24
|
return new require_api_ApiResponseClass.ApiResponseClass().setToError(data, response.statusText);
|
|
@@ -12,7 +12,10 @@ const deleteRequest = async (url, config = {}) => {
|
|
|
12
12
|
throwHttpErrors: false,
|
|
13
13
|
...config
|
|
14
14
|
}).then(async (response) => {
|
|
15
|
-
const
|
|
15
|
+
const isJson = (response.headers.get("content-type") || "").includes("application/json");
|
|
16
|
+
let data;
|
|
17
|
+
if (isJson) data = await response.json();
|
|
18
|
+
else data = await response.text();
|
|
16
19
|
if (void 0 !== data.body && void 0 !== data.error && void 0 !== data.state) return new ApiResponseClass(data);
|
|
17
20
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(data);
|
|
18
21
|
return new ApiResponseClass().setToError(data, response.statusText);
|
package/dist/api/get.cjs
CHANGED
|
@@ -14,7 +14,10 @@ const get = async (url, config = {}) => {
|
|
|
14
14
|
throwHttpErrors: false,
|
|
15
15
|
...config
|
|
16
16
|
}).then(async (response) => {
|
|
17
|
-
const
|
|
17
|
+
const isJson = (response.headers.get("content-type") || "").includes("application/json");
|
|
18
|
+
let data;
|
|
19
|
+
if (isJson) data = await response.json();
|
|
20
|
+
else data = await response.text();
|
|
18
21
|
if (void 0 !== data.body && void 0 !== data.error && void 0 !== data.state) return new require_api_ApiResponseClass.ApiResponseClass(data);
|
|
19
22
|
else if (response.status >= 200 && response.status <= 299) return new require_api_ApiResponseClass.ApiResponseClass().setToSuccess(data);
|
|
20
23
|
return new require_api_ApiResponseClass.ApiResponseClass().setToError(data, response.statusText);
|
package/dist/api/get.mjs
CHANGED
|
@@ -11,7 +11,10 @@ const get = async (url, config = {}) => {
|
|
|
11
11
|
throwHttpErrors: false,
|
|
12
12
|
...config
|
|
13
13
|
}).then(async (response) => {
|
|
14
|
-
const
|
|
14
|
+
const isJson = (response.headers.get("content-type") || "").includes("application/json");
|
|
15
|
+
let data;
|
|
16
|
+
if (isJson) data = await response.json();
|
|
17
|
+
else data = await response.text();
|
|
15
18
|
if (void 0 !== data.body && void 0 !== data.error && void 0 !== data.state) return new ApiResponseClass(data);
|
|
16
19
|
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(data);
|
|
17
20
|
return new ApiResponseClass().setToError(data, response.statusText);
|
package/dist/api/post.cjs
CHANGED
|
@@ -15,10 +15,13 @@ const post = async (url, data = {}, config = {}) => {
|
|
|
15
15
|
throwHttpErrors: false,
|
|
16
16
|
...config
|
|
17
17
|
}).then(async (response) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
const isJson = (response.headers.get("content-type") || "").includes("application/json");
|
|
19
|
+
let data;
|
|
20
|
+
if (isJson) data = await response.json();
|
|
21
|
+
else data = await response.text();
|
|
22
|
+
if (void 0 !== data.body && void 0 !== data.error && void 0 !== data.state) return new require_api_ApiResponseClass.ApiResponseClass(data);
|
|
23
|
+
else if (response.status >= 200 && response.status <= 299) return new require_api_ApiResponseClass.ApiResponseClass().setToSuccess(data);
|
|
24
|
+
return new require_api_ApiResponseClass.ApiResponseClass().setToError(data, response.statusText);
|
|
22
25
|
}).catch((error) => {
|
|
23
26
|
return new require_api_ApiResponseClass.ApiResponseClass().setToError(null, error.message);
|
|
24
27
|
});
|
package/dist/api/post.mjs
CHANGED
|
@@ -12,10 +12,13 @@ const post = async (url, data = {}, config = {}) => {
|
|
|
12
12
|
throwHttpErrors: false,
|
|
13
13
|
...config
|
|
14
14
|
}).then(async (response) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const isJson = (response.headers.get("content-type") || "").includes("application/json");
|
|
16
|
+
let data;
|
|
17
|
+
if (isJson) data = await response.json();
|
|
18
|
+
else data = await response.text();
|
|
19
|
+
if (void 0 !== data.body && void 0 !== data.error && void 0 !== data.state) return new ApiResponseClass(data);
|
|
20
|
+
else if (response.status >= 200 && response.status <= 299) return new ApiResponseClass().setToSuccess(data);
|
|
21
|
+
return new ApiResponseClass().setToError(data, response.statusText);
|
|
19
22
|
}).catch((error) => {
|
|
20
23
|
return new ApiResponseClass().setToError(null, error.message);
|
|
21
24
|
});
|