@ventlio/tanstack-query 0.2.61 → 0.2.62
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/index.mjs +7 -8
- package/dist/index.mjs.map +1 -1
- package/dist/request/axios-instance.d.ts +2 -3
- package/dist/request/axios-instance.js +4 -6
- package/dist/request/axios-instance.js.map +1 -1
- package/dist/request/make-request.js +3 -2
- package/dist/request/make-request.js.map +1 -1
- package/package.json +1 -1
- package/src/request/axios-instance.ts +8 -9
- package/src/request/make-request.ts +5 -2
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQueryClient, useQuery, useMutation } from '@tanstack/react-query';
|
|
2
2
|
import { useState, useEffect, useMemo, startTransition } from 'react';
|
|
3
|
-
import
|
|
3
|
+
import { Axios } from 'axios';
|
|
4
4
|
|
|
5
5
|
const bootstrapQueryRequest = (queryClient, options) => {
|
|
6
6
|
// make query config doesn't expire
|
|
@@ -124,12 +124,10 @@ const useRefetchQuery = async (queryKey) => {
|
|
|
124
124
|
return { refetchQuery };
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
const axiosInstance = (
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
headers,
|
|
132
|
-
});
|
|
127
|
+
const axiosInstance = (method) => {
|
|
128
|
+
const axiosI = new Axios();
|
|
129
|
+
const requestMethod = method.toLowerCase();
|
|
130
|
+
return axiosI[requestMethod];
|
|
133
131
|
};
|
|
134
132
|
|
|
135
133
|
const buildFormData = (body) => {
|
|
@@ -220,8 +218,9 @@ async function makeRequest({ body, method = HttpMethod.GET, path, isFormData, he
|
|
|
220
218
|
delete headers['Content-Type'];
|
|
221
219
|
}
|
|
222
220
|
try {
|
|
221
|
+
const axios = axiosInstance(method);
|
|
223
222
|
// send request
|
|
224
|
-
const resp = await axios({ baseURL,
|
|
223
|
+
const resp = await axios(path, { baseURL, headers, timeout });
|
|
225
224
|
// get response json
|
|
226
225
|
const jsonResp = await resp.data;
|
|
227
226
|
// get response code
|
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
3
|
-
export declare const axiosInstance: ({ baseURL, timeout, headers }: Partial<IMakeRequest>) => AxiosInstance;
|
|
1
|
+
import type { HttpMethod } from './request.enum';
|
|
2
|
+
export declare const axiosInstance: (method: HttpMethod) => (<T = any, R = import("axios").AxiosResponse<T, any>, D = any>(url: string, config?: import("axios").AxiosRequestConfig<D> | undefined) => Promise<R>) | (<T_1 = any, R_1 = import("axios").AxiosResponse<T_1, any>, D_1 = any>(url: string, data?: D_1 | undefined, config?: import("axios").AxiosRequestConfig<D_1> | undefined) => Promise<R_1>) | (<T_2 = any, R_2 = import("axios").AxiosResponse<T_2, any>, D_2 = any>(url: string, data?: D_2 | undefined, config?: import("axios").AxiosRequestConfig<D_2> | undefined) => Promise<R_2>) | (<T_3 = any, R_3 = import("axios").AxiosResponse<T_3, any>, D_3 = any>(url: string, data?: D_3 | undefined, config?: import("axios").AxiosRequestConfig<D_3> | undefined) => Promise<R_3>) | (<T_4 = any, R_4 = import("axios").AxiosResponse<T_4, any>, D_4 = any>(url: string, config?: import("axios").AxiosRequestConfig<D_4> | undefined) => Promise<R_4>);
|
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
|
|
5
|
-
const axiosInstance = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
headers,
|
|
10
|
-
});
|
|
5
|
+
const axiosInstance = (method) => {
|
|
6
|
+
const axiosI = new axios.Axios();
|
|
7
|
+
const requestMethod = method.toLowerCase();
|
|
8
|
+
return axiosI[requestMethod];
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
exports.axiosInstance = axiosInstance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axios-instance.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"axios-instance.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var axiosInstance = require('./axios-instance.js');
|
|
4
4
|
var buildFormData = require('./buildFormData.js');
|
|
5
5
|
var request_enum = require('./request.enum.js');
|
|
6
6
|
var transformer = require('./transformer.js');
|
|
@@ -16,8 +16,9 @@ async function makeRequest({ body, method = request_enum.HttpMethod.GET, path, i
|
|
|
16
16
|
delete headers['Content-Type'];
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
+
const axios = axiosInstance.axiosInstance(method);
|
|
19
20
|
// send request
|
|
20
|
-
const resp = await axios({ baseURL,
|
|
21
|
+
const resp = await axios(path, { baseURL, headers, timeout });
|
|
21
22
|
// get response json
|
|
22
23
|
const jsonResp = await resp.data;
|
|
23
24
|
// get response code
|
|
@@ -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,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import type { IMakeRequest } from './request.interface';
|
|
1
|
+
import { Axios } from 'axios';
|
|
2
|
+
import type { HttpMethod } from './request.enum';
|
|
4
3
|
|
|
5
|
-
export const axiosInstance = (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export const axiosInstance = (method: HttpMethod) => {
|
|
5
|
+
const axiosI = new Axios();
|
|
6
|
+
|
|
7
|
+
const requestMethod = method.toLowerCase() as Lowercase<HttpMethod>;
|
|
8
|
+
|
|
9
|
+
return axiosI[requestMethod];
|
|
11
10
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { axiosInstance } from './axios-instance';
|
|
2
|
+
|
|
2
3
|
import { buildFormData } from './buildFormData';
|
|
3
4
|
import { ContentType, HttpMethod } from './request.enum';
|
|
4
5
|
import type { IMakeRequest } from './request.interface';
|
|
@@ -24,8 +25,10 @@ export async function makeRequest<TResponse>({
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
try {
|
|
28
|
+
const axios = axiosInstance(method);
|
|
29
|
+
|
|
27
30
|
// send request
|
|
28
|
-
const resp = await axios({ baseURL,
|
|
31
|
+
const resp = await axios(path, { baseURL, headers, timeout });
|
|
29
32
|
|
|
30
33
|
// get response json
|
|
31
34
|
const jsonResp: any = await resp.data;
|