@ventlio/tanstack-query 0.2.60 → 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 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 axios from 'axios';
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 = ({ baseURL, timeout, headers }) => {
128
- return axios.create({
129
- baseURL,
130
- timeout,
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,13 +218,9 @@ async function makeRequest({ body, method = HttpMethod.GET, path, isFormData, he
220
218
  delete headers['Content-Type'];
221
219
  }
222
220
  try {
223
- const axios = axiosInstance({ baseURL, headers, timeout });
221
+ const axios = axiosInstance(method);
224
222
  // send request
225
- const resp = await axios({
226
- url: path,
227
- method,
228
- data: body,
229
- });
223
+ const resp = await axios(path, { baseURL, headers, timeout });
230
224
  // get response json
231
225
  const jsonResp = await resp.data;
232
226
  // get response code
@@ -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 { AxiosInstance } from 'axios';
2
- import type { IMakeRequest } from './request.interface';
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 = ({ baseURL, timeout, headers }) => {
6
- return axios.create({
7
- baseURL,
8
- timeout,
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":";;;;;;;;;;;;"}
@@ -16,13 +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({ baseURL, headers, timeout });
19
+ const axios = axiosInstance.axiosInstance(method);
20
20
  // send request
21
- const resp = await axios({
22
- url: path,
23
- method,
24
- data: body,
25
- });
21
+ const resp = await axios(path, { baseURL, headers, timeout });
26
22
  // get response json
27
23
  const jsonResp = await resp.data;
28
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@ventlio/tanstack-query",
3
- "version": "0.2.60",
3
+ "version": "0.2.62",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "contributors": [
@@ -1,11 +1,10 @@
1
- import type { AxiosInstance } from 'axios';
2
- import axios from 'axios';
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 = ({ baseURL, timeout, headers }: Partial<IMakeRequest>): AxiosInstance => {
6
- return axios.create({
7
- baseURL,
8
- timeout,
9
- headers,
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
  };
@@ -25,14 +25,10 @@ export async function makeRequest<TResponse>({
25
25
  }
26
26
 
27
27
  try {
28
- const axios = axiosInstance({ baseURL, headers, timeout });
28
+ const axios = axiosInstance(method);
29
29
 
30
30
  // send request
31
- const resp = await axios({
32
- url: path,
33
- method,
34
- data: body,
35
- });
31
+ const resp = await axios(path, { baseURL, headers, timeout });
36
32
 
37
33
  // get response json
38
34
  const jsonResp: any = await resp.data;