@ventlio/tanstack-query 0.2.15 → 0.2.17
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 +1 -3
- package/dist/config/useQueryConfig.js.map +1 -1
- package/dist/index.mjs +3 -3
- package/dist/request/make-request.js +2 -0
- package/dist/request/make-request.js.map +1 -1
- package/package.json +1 -1
- package/src/config/useQueryConfig.ts +1 -3
- package/src/request/make-request.ts +2 -0
|
@@ -4,9 +4,7 @@ var reactQuery = require('@tanstack/react-query');
|
|
|
4
4
|
|
|
5
5
|
const useQueryConfig = () => {
|
|
6
6
|
const queryClient = reactQuery.useQueryClient();
|
|
7
|
-
const { headers = {}, baseURL = '', timeout = 10000, } = queryClient.getQueryData([
|
|
8
|
-
'config',
|
|
9
|
-
]);
|
|
7
|
+
const { headers = {}, baseURL = '', timeout = 10000, } = queryClient.getQueryData(['config']) ?? {};
|
|
10
8
|
return { headers, baseURL, timeout };
|
|
11
9
|
};
|
|
12
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryConfig.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useQueryConfig.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -4,9 +4,7 @@ import axios from 'axios';
|
|
|
4
4
|
|
|
5
5
|
const useQueryConfig = () => {
|
|
6
6
|
const queryClient = useQueryClient();
|
|
7
|
-
const { headers = {}, baseURL = '', timeout = 10000, } = queryClient.getQueryData([
|
|
8
|
-
'config',
|
|
9
|
-
]);
|
|
7
|
+
const { headers = {}, baseURL = '', timeout = 10000, } = queryClient.getQueryData(['config']) ?? {};
|
|
10
8
|
return { headers, baseURL, timeout };
|
|
11
9
|
};
|
|
12
10
|
|
|
@@ -173,10 +171,12 @@ async function makeRequest({ body, method = HttpMethod.GET, path, isFormData, he
|
|
|
173
171
|
});
|
|
174
172
|
}
|
|
175
173
|
catch (error) {
|
|
174
|
+
const errorData = error.response.data;
|
|
176
175
|
return errorTransformer({
|
|
177
176
|
statusCode: error.status,
|
|
178
177
|
message: error.message,
|
|
179
178
|
code: error.status || error.statusCode,
|
|
179
|
+
...errorData,
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -34,10 +34,12 @@ async function makeRequest({ body, method = request_enum.HttpMethod.GET, path, i
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
catch (error) {
|
|
37
|
+
const errorData = error.response.data;
|
|
37
38
|
return transformer.errorTransformer({
|
|
38
39
|
statusCode: error.status,
|
|
39
40
|
message: error.message,
|
|
40
41
|
code: error.status || error.statusCode,
|
|
42
|
+
...errorData,
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-request.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"make-request.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -8,9 +8,7 @@ export const useQueryConfig = (): TanstackQueryConfig => {
|
|
|
8
8
|
headers = {},
|
|
9
9
|
baseURL = '',
|
|
10
10
|
timeout = 10000,
|
|
11
|
-
} = queryClient.getQueryData<TanstackQueryConfig>([
|
|
12
|
-
'config',
|
|
13
|
-
]) as TanstackQueryConfig;
|
|
11
|
+
} = queryClient.getQueryData<TanstackQueryConfig>(['config']) ?? {};
|
|
14
12
|
|
|
15
13
|
return { headers, baseURL, timeout };
|
|
16
14
|
};
|
|
@@ -49,10 +49,12 @@ export async function makeRequest<TResponse>({
|
|
|
49
49
|
statusCode: responseCode,
|
|
50
50
|
});
|
|
51
51
|
} catch (error: any) {
|
|
52
|
+
const errorData = error.response.data;
|
|
52
53
|
return errorTransformer({
|
|
53
54
|
statusCode: error.status,
|
|
54
55
|
message: error.message,
|
|
55
56
|
code: error.status || error.statusCode,
|
|
57
|
+
...errorData,
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
}
|