@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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ventlio/tanstack-query",
3
- "version": "0.2.15",
3
+ "version": "0.2.17",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "contributors": [
@@ -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
  }