@ventlio/tanstack-query 0.2.65 → 0.2.66
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/config/useQueryConfig.js +2 -2
- package/dist/index.mjs +40 -20
- package/dist/index.mjs.map +1 -1
- package/dist/model/model.interface.d.ts +2 -0
- package/dist/model/useQueryModel.js +20 -5
- package/dist/model/useQueryModel.js.map +1 -1
- package/dist/model/useRefetchQuery.js +2 -2
- package/dist/queries/useGetRequest.js +16 -11
- package/dist/queries/useGetRequest.js.map +1 -1
- package/package.json +1 -1
- package/src/config/useQueryConfig.ts +2 -2
- package/src/model/model.interface.ts +2 -0
- package/src/model/useQueryModel.ts +23 -6
- package/src/model/useRefetchQuery.ts +2 -2
- package/src/queries/useGetRequest.ts +16 -12
|
@@ -2,8 +2,8 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
|
|
3
3
|
const useQueryConfig = () => {
|
|
4
4
|
const queryClient = useQueryClient();
|
|
5
|
-
const { headers = {} } = queryClient.getQueryData(['config']) ?? {};
|
|
6
|
-
return { headers };
|
|
5
|
+
const { headers = {}, options = {} } = queryClient.getQueryData(['config']) ?? {};
|
|
6
|
+
return { headers, options };
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
export { useQueryConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQueryClient, useQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import result from 'lodash.result';
|
|
3
|
-
import
|
|
3
|
+
import lodashSet from 'lodash.set';
|
|
4
4
|
import { useState, useMemo, useEffect, startTransition } from 'react';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
|
|
@@ -40,8 +40,8 @@ const useEnvironmentVariables = () => {
|
|
|
40
40
|
|
|
41
41
|
const useQueryConfig = () => {
|
|
42
42
|
const queryClient = useQueryClient();
|
|
43
|
-
const { headers = {} } = queryClient.getQueryData(['config']) ?? {};
|
|
44
|
-
return { headers };
|
|
43
|
+
const { headers = {}, options = {} } = queryClient.getQueryData(['config']) ?? {};
|
|
44
|
+
return { headers, options };
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
const scrollToTop = () => {
|
|
@@ -117,7 +117,7 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
117
117
|
}
|
|
118
118
|
else {
|
|
119
119
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
120
|
-
queryClient.setQueryData(queryKey,
|
|
120
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, records));
|
|
121
121
|
}
|
|
122
122
|
return data;
|
|
123
123
|
};
|
|
@@ -143,6 +143,21 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
143
143
|
const data = findAll(path) ?? [];
|
|
144
144
|
return data.find((record) => record[modelConfig.idColumn] === id);
|
|
145
145
|
};
|
|
146
|
+
const get = (path) => {
|
|
147
|
+
let data = queryClient.getQueryData(queryKey, { exact });
|
|
148
|
+
if (path) {
|
|
149
|
+
data = result(data, path);
|
|
150
|
+
}
|
|
151
|
+
return data;
|
|
152
|
+
};
|
|
153
|
+
const set = (newData, path) => {
|
|
154
|
+
if (path) {
|
|
155
|
+
const data = get();
|
|
156
|
+
newData = lodashSet(data, path, newData);
|
|
157
|
+
return queryClient.setQueryData(queryKey, newData);
|
|
158
|
+
}
|
|
159
|
+
return queryClient.setQueryData(queryKey, newData);
|
|
160
|
+
};
|
|
146
161
|
const getModelConfig = () => {
|
|
147
162
|
const { options } = queryClient.getQueryData(['config']) ?? {};
|
|
148
163
|
const { modelConfig } = options ?? {};
|
|
@@ -169,7 +184,7 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
169
184
|
}
|
|
170
185
|
else {
|
|
171
186
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
172
|
-
queryClient.setQueryData(queryKey,
|
|
187
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, newData));
|
|
173
188
|
}
|
|
174
189
|
return updatedRecord;
|
|
175
190
|
};
|
|
@@ -194,18 +209,18 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
194
209
|
}
|
|
195
210
|
else {
|
|
196
211
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
197
|
-
queryClient.setQueryData(queryKey,
|
|
212
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, newData));
|
|
198
213
|
}
|
|
199
214
|
return updated;
|
|
200
215
|
};
|
|
201
|
-
return { find, findAll, findMany, remove, update, add };
|
|
216
|
+
return { find, findAll, findMany, remove, update, add, get, set };
|
|
202
217
|
};
|
|
203
218
|
|
|
204
219
|
const useRefetchQuery = async (queryKey) => {
|
|
205
220
|
const queryClient = useQueryClient();
|
|
206
221
|
const refetchQuery = async (innerQueryKey) => {
|
|
207
|
-
await queryClient.
|
|
208
|
-
queryKey,
|
|
222
|
+
await queryClient.invalidateQueries({
|
|
223
|
+
queryKey: innerQueryKey ?? queryKey,
|
|
209
224
|
exact: true,
|
|
210
225
|
}, { throwOnError: true, cancelRefetch: true });
|
|
211
226
|
return queryClient.getQueriesData(innerQueryKey ?? queryKey);
|
|
@@ -426,19 +441,24 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
|
|
|
426
441
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
427
442
|
queryClient = useMemo(() => queryClient, []);
|
|
428
443
|
const sendRequest = async (res, rej) => {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
444
|
+
if (load) {
|
|
445
|
+
// get request headers
|
|
446
|
+
const globalHeaders = getHeaders();
|
|
447
|
+
const getResponse = await makeRequest({
|
|
448
|
+
path: requestPath,
|
|
449
|
+
headers: { ...globalHeaders, ...headers },
|
|
450
|
+
baseURL: baseUrl ?? API_URL,
|
|
451
|
+
timeout: TIMEOUT,
|
|
452
|
+
});
|
|
453
|
+
if (getResponse.status) {
|
|
454
|
+
res(getResponse);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
rej(getResponse);
|
|
458
|
+
}
|
|
439
459
|
}
|
|
440
460
|
else {
|
|
441
|
-
|
|
461
|
+
res(null);
|
|
442
462
|
}
|
|
443
463
|
};
|
|
444
464
|
const query = useQuery([requestPath, {}], () => new Promise((res, rej) => sendRequest(res, rej)), {
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5,5 +5,7 @@ export interface QueryModelBuilder<T> {
|
|
|
5
5
|
find: (id: number | string, path?: string) => T | undefined;
|
|
6
6
|
update: (id: number | string, data: Partial<T>, path?: string) => T | undefined;
|
|
7
7
|
remove: (id: number, path?: string) => boolean;
|
|
8
|
+
get: (path?: string) => T | undefined;
|
|
9
|
+
set: (data: Partial<T>, path?: string) => T | undefined;
|
|
8
10
|
}
|
|
9
11
|
export type QueryModelAddPosition = 'start' | 'end';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import result from 'lodash.result';
|
|
3
|
-
import
|
|
3
|
+
import lodashSet from 'lodash.set';
|
|
4
4
|
import { useKeyTrackerModel } from './useKeyTrackerModel.js';
|
|
5
5
|
|
|
6
6
|
const useQueryModel = (keyTracker, exact = true) => {
|
|
@@ -21,7 +21,7 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
24
|
-
queryClient.setQueryData(queryKey,
|
|
24
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, records));
|
|
25
25
|
}
|
|
26
26
|
return data;
|
|
27
27
|
};
|
|
@@ -47,6 +47,21 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
47
47
|
const data = findAll(path) ?? [];
|
|
48
48
|
return data.find((record) => record[modelConfig.idColumn] === id);
|
|
49
49
|
};
|
|
50
|
+
const get = (path) => {
|
|
51
|
+
let data = queryClient.getQueryData(queryKey, { exact });
|
|
52
|
+
if (path) {
|
|
53
|
+
data = result(data, path);
|
|
54
|
+
}
|
|
55
|
+
return data;
|
|
56
|
+
};
|
|
57
|
+
const set = (newData, path) => {
|
|
58
|
+
if (path) {
|
|
59
|
+
const data = get();
|
|
60
|
+
newData = lodashSet(data, path, newData);
|
|
61
|
+
return queryClient.setQueryData(queryKey, newData);
|
|
62
|
+
}
|
|
63
|
+
return queryClient.setQueryData(queryKey, newData);
|
|
64
|
+
};
|
|
50
65
|
const getModelConfig = () => {
|
|
51
66
|
const { options } = queryClient.getQueryData(['config']) ?? {};
|
|
52
67
|
const { modelConfig } = options ?? {};
|
|
@@ -73,7 +88,7 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
73
88
|
}
|
|
74
89
|
else {
|
|
75
90
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
76
|
-
queryClient.setQueryData(queryKey,
|
|
91
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, newData));
|
|
77
92
|
}
|
|
78
93
|
return updatedRecord;
|
|
79
94
|
};
|
|
@@ -98,11 +113,11 @@ const useQueryModel = (keyTracker, exact = true) => {
|
|
|
98
113
|
}
|
|
99
114
|
else {
|
|
100
115
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
101
|
-
queryClient.setQueryData(queryKey,
|
|
116
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, newData));
|
|
102
117
|
}
|
|
103
118
|
return updated;
|
|
104
119
|
};
|
|
105
|
-
return { find, findAll, findMany, remove, update, add };
|
|
120
|
+
return { find, findAll, findMany, remove, update, add, get, set };
|
|
106
121
|
};
|
|
107
122
|
|
|
108
123
|
export { useQueryModel };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryModel.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryModel.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,8 +3,8 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
3
3
|
const useRefetchQuery = async (queryKey) => {
|
|
4
4
|
const queryClient = useQueryClient();
|
|
5
5
|
const refetchQuery = async (innerQueryKey) => {
|
|
6
|
-
await queryClient.
|
|
7
|
-
queryKey,
|
|
6
|
+
await queryClient.invalidateQueries({
|
|
7
|
+
queryKey: innerQueryKey ?? queryKey,
|
|
8
8
|
exact: true,
|
|
9
9
|
}, { throwOnError: true, cancelRefetch: true });
|
|
10
10
|
return queryClient.getQueriesData(innerQueryKey ?? queryKey);
|
|
@@ -16,19 +16,24 @@ const useGetRequest = ({ path, load = false, queryOptions, keyTracker, baseUrl,
|
|
|
16
16
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
17
17
|
queryClient = useMemo(() => queryClient, []);
|
|
18
18
|
const sendRequest = async (res, rej) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
if (load) {
|
|
20
|
+
// get request headers
|
|
21
|
+
const globalHeaders = getHeaders();
|
|
22
|
+
const getResponse = await makeRequest({
|
|
23
|
+
path: requestPath,
|
|
24
|
+
headers: { ...globalHeaders, ...headers },
|
|
25
|
+
baseURL: baseUrl ?? API_URL,
|
|
26
|
+
timeout: TIMEOUT,
|
|
27
|
+
});
|
|
28
|
+
if (getResponse.status) {
|
|
29
|
+
res(getResponse);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
rej(getResponse);
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
else {
|
|
31
|
-
|
|
36
|
+
res(null);
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
39
|
const query = useQuery([requestPath, {}], () => new Promise((res, rej) => sendRequest(res, rej)), {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useGetRequest.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import type { TanstackQueryConfig } from '../types';
|
|
|
4
4
|
export const useQueryConfig = (): TanstackQueryConfig => {
|
|
5
5
|
const queryClient = useQueryClient();
|
|
6
6
|
|
|
7
|
-
const { headers = {} } = queryClient.getQueryData<TanstackQueryConfig>(['config']) ?? {};
|
|
7
|
+
const { headers = {}, options = {} } = queryClient.getQueryData<TanstackQueryConfig>(['config']) ?? {};
|
|
8
8
|
|
|
9
|
-
return { headers };
|
|
9
|
+
return { headers, options };
|
|
10
10
|
};
|
|
@@ -5,6 +5,8 @@ export interface QueryModelBuilder<T> {
|
|
|
5
5
|
find: (id: number | string, path?: string) => T | undefined;
|
|
6
6
|
update: (id: number | string, data: Partial<T>, path?: string) => T | undefined;
|
|
7
7
|
remove: (id: number, path?: string) => boolean;
|
|
8
|
+
get: (path?: string) => T | undefined;
|
|
9
|
+
set: (data: Partial<T>, path?: string) => T | undefined;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export type QueryModelAddPosition = 'start' | 'end';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import result from 'lodash.result';
|
|
3
|
-
import
|
|
3
|
+
import { default as lodashSet } from 'lodash.set';
|
|
4
4
|
import type { TanstackQueryConfig } from '../types';
|
|
5
5
|
import type { QueryModelAddPosition, QueryModelBuilder } from './model.interface';
|
|
6
6
|
import { useKeyTrackerModel } from './useKeyTrackerModel';
|
|
@@ -24,7 +24,7 @@ export const useQueryModel = <T>(keyTracker: string, exact: boolean = true): Que
|
|
|
24
24
|
queryClient.setQueryData(queryKey, records);
|
|
25
25
|
} else {
|
|
26
26
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
27
|
-
queryClient.setQueryData(queryKey,
|
|
27
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, records));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return data;
|
|
@@ -60,6 +60,24 @@ export const useQueryModel = <T>(keyTracker: string, exact: boolean = true): Que
|
|
|
60
60
|
return data.find((record) => (record as Record<string, any>)[modelConfig.idColumn] === id);
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
const get = (path?: string): T | undefined => {
|
|
64
|
+
let data = queryClient.getQueryData(queryKey, { exact });
|
|
65
|
+
if (path) {
|
|
66
|
+
data = result<T>(data, path);
|
|
67
|
+
}
|
|
68
|
+
return data as T;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const set = (newData: any, path?: string): T | undefined => {
|
|
72
|
+
if (path) {
|
|
73
|
+
const data = get() as any;
|
|
74
|
+
newData = lodashSet(data, path, newData);
|
|
75
|
+
|
|
76
|
+
return queryClient.setQueryData(queryKey, newData) as T;
|
|
77
|
+
}
|
|
78
|
+
return queryClient.setQueryData(queryKey, newData) as T;
|
|
79
|
+
};
|
|
80
|
+
|
|
63
81
|
const getModelConfig = () => {
|
|
64
82
|
const { options } = queryClient.getQueryData<TanstackQueryConfig>(['config']) ?? {};
|
|
65
83
|
const { modelConfig } = options ?? {};
|
|
@@ -79,7 +97,6 @@ export const useQueryModel = <T>(keyTracker: string, exact: boolean = true): Que
|
|
|
79
97
|
let updatedRecord: T | undefined = undefined;
|
|
80
98
|
const newData = oldData.map((record) => {
|
|
81
99
|
let dataRecord = record as Record<string, any>;
|
|
82
|
-
|
|
83
100
|
if (dataRecord[idColumn] === id) {
|
|
84
101
|
dataRecord = { ...dataRecord, ...data };
|
|
85
102
|
updatedRecord = dataRecord as T;
|
|
@@ -92,7 +109,7 @@ export const useQueryModel = <T>(keyTracker: string, exact: boolean = true): Que
|
|
|
92
109
|
queryClient.setQueryData(queryKey, newData);
|
|
93
110
|
} else {
|
|
94
111
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
95
|
-
queryClient.setQueryData(queryKey,
|
|
112
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, newData));
|
|
96
113
|
}
|
|
97
114
|
return updatedRecord;
|
|
98
115
|
};
|
|
@@ -119,10 +136,10 @@ export const useQueryModel = <T>(keyTracker: string, exact: boolean = true): Que
|
|
|
119
136
|
queryClient.setQueryData(queryKey, newData);
|
|
120
137
|
} else {
|
|
121
138
|
const queryData = queryClient.getQueryData(queryKey, { exact }) ?? {};
|
|
122
|
-
queryClient.setQueryData(queryKey,
|
|
139
|
+
queryClient.setQueryData(queryKey, lodashSet(queryData, path, newData));
|
|
123
140
|
}
|
|
124
141
|
return updated;
|
|
125
142
|
};
|
|
126
143
|
|
|
127
|
-
return { find, findAll, findMany, remove, update, add };
|
|
144
|
+
return { find, findAll, findMany, remove, update, add, get, set };
|
|
128
145
|
};
|
|
@@ -4,9 +4,9 @@ export const useRefetchQuery = async (queryKey: any[]) => {
|
|
|
4
4
|
const queryClient = useQueryClient();
|
|
5
5
|
|
|
6
6
|
const refetchQuery = async <T>(innerQueryKey?: any[]) => {
|
|
7
|
-
await queryClient.
|
|
7
|
+
await queryClient.invalidateQueries(
|
|
8
8
|
{
|
|
9
|
-
queryKey,
|
|
9
|
+
queryKey: innerQueryKey ?? queryKey,
|
|
10
10
|
exact: true,
|
|
11
11
|
},
|
|
12
12
|
{ throwOnError: true, cancelRefetch: true }
|
|
@@ -39,20 +39,24 @@ export const useGetRequest = <TResponse extends Record<string, any>>({
|
|
|
39
39
|
) => void,
|
|
40
40
|
rej: (reason?: any) => void
|
|
41
41
|
) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
if (load) {
|
|
43
|
+
// get request headers
|
|
44
|
+
const globalHeaders: RawAxiosRequestHeaders = getHeaders();
|
|
45
|
+
|
|
46
|
+
const getResponse = await makeRequest<TResponse>({
|
|
47
|
+
path: requestPath,
|
|
48
|
+
headers: { ...globalHeaders, ...headers },
|
|
49
|
+
baseURL: baseUrl ?? API_URL,
|
|
50
|
+
timeout: TIMEOUT,
|
|
51
|
+
});
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
if (getResponse.status) {
|
|
54
|
+
res(getResponse as IRequestSuccess<TResponse>);
|
|
55
|
+
} else {
|
|
56
|
+
rej(getResponse);
|
|
57
|
+
}
|
|
54
58
|
} else {
|
|
55
|
-
|
|
59
|
+
res(null as any);
|
|
56
60
|
}
|
|
57
61
|
};
|
|
58
62
|
|