@marianmeres/http-utils 1.2.0 → 1.3.2
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/README.md +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/index.cjs +8 -10
- package/dist/index.js +8 -10
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/api.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ interface FetchParams {
|
|
|
12
12
|
assert?: null | boolean;
|
|
13
13
|
}
|
|
14
14
|
type BaseFetchParams = BaseParams & FetchParams;
|
|
15
|
-
export declare const createHttpApi: (base
|
|
15
|
+
export declare const createHttpApi: (base?: string | null, defaults?: Partial<BaseFetchParams> | (() => Promise<Partial<BaseFetchParams>>)) => {
|
|
16
16
|
get(path: string, params?: FetchParams, respHeaders?: null, _dumpParams?: boolean): Promise<string | BaseFetchParams | Response>;
|
|
17
17
|
post(path: string, data?: null, params?: FetchParams, respHeaders?: null, _dumpParams?: boolean): Promise<string | BaseFetchParams | Response>;
|
|
18
18
|
put(path: string, data?: null, params?: FetchParams, respHeaders?: null, _dumpParams?: boolean): Promise<string | BaseFetchParams | Response>;
|
package/dist/index.cjs
CHANGED
|
@@ -294,16 +294,14 @@ const createHttpApi = (base, defaults) => {
|
|
|
294
294
|
merge.dset(wrap, 'result', b);
|
|
295
295
|
return wrap.result;
|
|
296
296
|
};
|
|
297
|
-
const _getDefs = async () => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
});
|
|
306
|
-
};
|
|
297
|
+
const _getDefs = async () => new Promise(async (resolve) => {
|
|
298
|
+
if (typeof defaults === 'function') {
|
|
299
|
+
resolve({ ...(await defaults()) });
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
resolve({ ...(defaults || {}) });
|
|
303
|
+
}
|
|
304
|
+
});
|
|
307
305
|
return {
|
|
308
306
|
// GET
|
|
309
307
|
async get(path, params, respHeaders = null, _dumpParams = false) {
|
package/dist/index.js
CHANGED
|
@@ -292,16 +292,14 @@ const createHttpApi = (base, defaults) => {
|
|
|
292
292
|
dset(wrap, 'result', b);
|
|
293
293
|
return wrap.result;
|
|
294
294
|
};
|
|
295
|
-
const _getDefs = async () => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
};
|
|
295
|
+
const _getDefs = async () => new Promise(async (resolve) => {
|
|
296
|
+
if (typeof defaults === 'function') {
|
|
297
|
+
resolve({ ...(await defaults()) });
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
resolve({ ...(defaults || {}) });
|
|
301
|
+
}
|
|
302
|
+
});
|
|
305
303
|
return {
|
|
306
304
|
// GET
|
|
307
305
|
async get(path, params, respHeaders = null, _dumpParams = false) {
|