@brostark/solutions-client 1.1.15 → 1.1.16
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpRequest.d.ts","sourceRoot":"","sources":["../../src/lib/httpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,KAAK,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"httpRequest.d.ts","sourceRoot":"","sources":["../../src/lib/httpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,KAAK,cAAc,GAAG,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAGF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAU,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,cAAc,iBA2CxF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,SAAS,WAAW,iBAOnF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,iBAI5D,CAAA;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,MAAM,OAAO,iBAK5E,CAAA;AAGD;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,iBAI/D,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,EAAE,MAAM,IAAI,iBAQ3E,CAAA"}
|
package/dist/lib/httpRequest.js
CHANGED
|
@@ -11,15 +11,12 @@ const constant_1 = require("../constant");
|
|
|
11
11
|
* @returns A promise with the request response
|
|
12
12
|
*/
|
|
13
13
|
const httpRequest = async (apiUrl, apiKey, options) => {
|
|
14
|
-
const { headers, params, data,
|
|
14
|
+
const { headers, params, data, ...rest } = options;
|
|
15
15
|
const url = (0, helper_1.buildUrlWithParams)(apiUrl, params);
|
|
16
|
-
const controller = typeof timeoutValue === "number" ? new AbortController() : undefined;
|
|
17
|
-
const timeoutId = typeof timeoutValue === "number" ? setTimeout(() => controller.abort(), timeoutValue) : undefined;
|
|
18
16
|
const config = (0, helper_1.removeUndefinedValues)({
|
|
19
17
|
mode: "cors",
|
|
20
18
|
method: "GET",
|
|
21
19
|
...rest,
|
|
22
|
-
signal: controller?.signal,
|
|
23
20
|
});
|
|
24
21
|
const finalHeaders = {
|
|
25
22
|
"x-api-key": apiKey,
|
|
@@ -50,11 +47,6 @@ const httpRequest = async (apiUrl, apiKey, options) => {
|
|
|
50
47
|
catch (e) {
|
|
51
48
|
return responseText;
|
|
52
49
|
}
|
|
53
|
-
finally {
|
|
54
|
-
if (timeoutId !== undefined) {
|
|
55
|
-
clearTimeout(timeoutId);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
50
|
};
|
|
59
51
|
exports.httpRequest = httpRequest;
|
|
60
52
|
/**
|
package/package.json
CHANGED
package/src/lib/httpRequest.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { MAX_LIMIT } from "../constant";
|
|
|
5
5
|
type RequestOptions = Omit<RequestInit, "body"> & {
|
|
6
6
|
params?: Record<string, unknown>;
|
|
7
7
|
data?: unknown;
|
|
8
|
-
timeout?: number;
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
|
|
@@ -17,17 +16,14 @@ type RequestOptions = Omit<RequestInit, "body"> & {
|
|
|
17
16
|
* @returns A promise with the request response
|
|
18
17
|
*/
|
|
19
18
|
export const httpRequest = async (apiUrl: string, apiKey: string, options: RequestOptions) => {
|
|
20
|
-
const { headers, params, data,
|
|
19
|
+
const { headers, params, data, ...rest } = options;
|
|
21
20
|
|
|
22
21
|
const url = buildUrlWithParams(apiUrl, params);
|
|
23
|
-
const controller = typeof timeoutValue === "number" ? new AbortController() : undefined;
|
|
24
|
-
const timeoutId = typeof timeoutValue === "number" ? setTimeout(() => controller!.abort(), timeoutValue) : undefined;
|
|
25
22
|
|
|
26
23
|
const config: RequestInit = removeUndefinedValues({
|
|
27
24
|
mode: "cors",
|
|
28
25
|
method: "GET",
|
|
29
26
|
...rest,
|
|
30
|
-
signal: controller?.signal,
|
|
31
27
|
});
|
|
32
28
|
|
|
33
29
|
const finalHeaders: Record<string, string> = {
|
|
@@ -61,10 +57,6 @@ export const httpRequest = async (apiUrl: string, apiKey: string, options: Reque
|
|
|
61
57
|
return JSON.parse(responseText);
|
|
62
58
|
} catch (e) {
|
|
63
59
|
return responseText;
|
|
64
|
-
} finally {
|
|
65
|
-
if (timeoutId !== undefined) {
|
|
66
|
-
clearTimeout(timeoutId);
|
|
67
|
-
}
|
|
68
60
|
}
|
|
69
61
|
}
|
|
70
62
|
|