@ventlio/tanstack-query 0.5.0 → 0.5.1
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 +21 -20
- package/dist/index.mjs.map +1 -1
- package/dist/request/make-request.js +21 -20
- package/dist/request/make-request.js.map +1 -1
- package/package.json +1 -1
- package/src/request/make-request.ts +22 -18
package/dist/index.mjs
CHANGED
|
@@ -347,35 +347,36 @@ async function makeRequest({ body = {}, method = HttpMethod.GET, path, isFormDat
|
|
|
347
347
|
if (!isFormData) {
|
|
348
348
|
headers['Content-Type'] = ContentType.APPLICATION_JSON;
|
|
349
349
|
}
|
|
350
|
-
else {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
body.append(fileKey, innerFile);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
body.append(fileKey, currentFile);
|
|
350
|
+
else if (isApp) {
|
|
351
|
+
headers['Content-Type'] = ContentType.MULTIPART_FORM_DATA;
|
|
352
|
+
// add the app files
|
|
353
|
+
for (const fileKey in appFiles) {
|
|
354
|
+
const currentFile = appFiles[fileKey];
|
|
355
|
+
if (Array.isArray(currentFile)) {
|
|
356
|
+
for (const innerFile of currentFile) {
|
|
357
|
+
body.append(fileKey, innerFile);
|
|
363
358
|
}
|
|
364
359
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
360
|
+
else {
|
|
361
|
+
body.append(fileKey, currentFile);
|
|
362
|
+
}
|
|
368
363
|
}
|
|
369
364
|
}
|
|
365
|
+
else {
|
|
366
|
+
delete headers['Content-Type'];
|
|
367
|
+
}
|
|
370
368
|
try {
|
|
371
369
|
const axiosRequest = axiosInstance({ baseURL, headers, timeout });
|
|
372
|
-
|
|
373
|
-
const resp = await axiosRequest({
|
|
370
|
+
const axiosRequestConfig = {
|
|
374
371
|
url: path,
|
|
375
372
|
method,
|
|
376
|
-
data: body,
|
|
377
373
|
onUploadProgress,
|
|
378
|
-
}
|
|
374
|
+
};
|
|
375
|
+
if (Object.keys(body).length > 0) {
|
|
376
|
+
axiosRequestConfig.data = body;
|
|
377
|
+
}
|
|
378
|
+
// send request
|
|
379
|
+
const resp = await axiosRequest(axiosRequestConfig);
|
|
379
380
|
// get response json
|
|
380
381
|
const jsonResp = await resp.data;
|
|
381
382
|
// 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -14,35 +14,36 @@ async function makeRequest({ body = {}, method = HttpMethod.GET, path, isFormDat
|
|
|
14
14
|
if (!isFormData) {
|
|
15
15
|
headers['Content-Type'] = ContentType.APPLICATION_JSON;
|
|
16
16
|
}
|
|
17
|
-
else {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
body.append(fileKey, innerFile);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
body.append(fileKey, currentFile);
|
|
17
|
+
else if (isApp) {
|
|
18
|
+
headers['Content-Type'] = ContentType.MULTIPART_FORM_DATA;
|
|
19
|
+
// add the app files
|
|
20
|
+
for (const fileKey in appFiles) {
|
|
21
|
+
const currentFile = appFiles[fileKey];
|
|
22
|
+
if (Array.isArray(currentFile)) {
|
|
23
|
+
for (const innerFile of currentFile) {
|
|
24
|
+
body.append(fileKey, innerFile);
|
|
30
25
|
}
|
|
31
26
|
}
|
|
27
|
+
else {
|
|
28
|
+
body.append(fileKey, currentFile);
|
|
29
|
+
}
|
|
32
30
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
delete headers['Content-Type'];
|
|
36
34
|
}
|
|
37
35
|
try {
|
|
38
36
|
const axiosRequest = axiosInstance({ baseURL, headers, timeout });
|
|
39
|
-
|
|
40
|
-
const resp = await axiosRequest({
|
|
37
|
+
const axiosRequestConfig = {
|
|
41
38
|
url: path,
|
|
42
39
|
method,
|
|
43
|
-
data: body,
|
|
44
40
|
onUploadProgress,
|
|
45
|
-
}
|
|
41
|
+
};
|
|
42
|
+
if (Object.keys(body).length > 0) {
|
|
43
|
+
axiosRequestConfig.data = body;
|
|
44
|
+
}
|
|
45
|
+
// send request
|
|
46
|
+
const resp = await axiosRequest(axiosRequestConfig);
|
|
46
47
|
// get response json
|
|
47
48
|
const jsonResp = await resp.data;
|
|
48
49
|
// 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,3 +1,4 @@
|
|
|
1
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
1
2
|
import axios from 'axios';
|
|
2
3
|
import { axiosInstance } from './axios-instance';
|
|
3
4
|
|
|
@@ -27,35 +28,38 @@ export async function makeRequest<TResponse>({
|
|
|
27
28
|
// configure request header1
|
|
28
29
|
if (!isFormData) {
|
|
29
30
|
headers['Content-Type'] = ContentType.APPLICATION_JSON;
|
|
30
|
-
} else {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
body.append(fileKey, innerFile);
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
body.append(fileKey, currentFile);
|
|
31
|
+
} else if (isApp) {
|
|
32
|
+
headers['Content-Type'] = ContentType.MULTIPART_FORM_DATA;
|
|
33
|
+
// add the app files
|
|
34
|
+
for (const fileKey in appFiles) {
|
|
35
|
+
const currentFile = appFiles[fileKey];
|
|
36
|
+
if (Array.isArray(currentFile)) {
|
|
37
|
+
for (const innerFile of currentFile) {
|
|
38
|
+
body.append(fileKey, innerFile);
|
|
42
39
|
}
|
|
40
|
+
} else {
|
|
41
|
+
body.append(fileKey, currentFile);
|
|
43
42
|
}
|
|
44
|
-
} else {
|
|
45
|
-
delete headers['Content-Type'];
|
|
46
43
|
}
|
|
44
|
+
} else {
|
|
45
|
+
delete headers['Content-Type'];
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
try {
|
|
50
49
|
const axiosRequest = axiosInstance({ baseURL, headers, timeout });
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
const resp = await axiosRequest({
|
|
51
|
+
const axiosRequestConfig: AxiosRequestConfig<Record<string, any>> = {
|
|
54
52
|
url: path,
|
|
55
53
|
method,
|
|
56
|
-
data: body,
|
|
57
54
|
onUploadProgress,
|
|
58
|
-
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (Object.keys(body).length > 0) {
|
|
58
|
+
axiosRequestConfig.data = body;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// send request
|
|
62
|
+
const resp = await axiosRequest(axiosRequestConfig);
|
|
59
63
|
|
|
60
64
|
// get response json
|
|
61
65
|
const jsonResp: any = await resp.data;
|