fets 0.7.2 → 0.8.0
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/cjs/client/createClient.js +2 -1
- package/cjs/utils.js +5 -1
- package/esm/client/createClient.js +2 -1
- package/esm/utils.js +3 -0
- package/package.json +1 -1
- package/typings/utils.d.cts +1 -0
- package/typings/utils.d.ts +1 -0
|
@@ -5,6 +5,7 @@ const qs_1 = require("qs");
|
|
|
5
5
|
const fetch_1 = require("@whatwg-node/fetch");
|
|
6
6
|
const server_1 = require("@whatwg-node/server");
|
|
7
7
|
const utils_js_1 = require("../plugins/utils.js");
|
|
8
|
+
const utils_js_2 = require("../utils.js");
|
|
8
9
|
const clientResponse_js_1 = require("./clientResponse.js");
|
|
9
10
|
const qsOptions = {
|
|
10
11
|
indices: false,
|
|
@@ -122,7 +123,7 @@ function createClient({ endpoint, fetchFn = fetch_1.fetch, plugins = [], globalP
|
|
|
122
123
|
for (const key in formDataBody) {
|
|
123
124
|
const value = formDataBody[key];
|
|
124
125
|
if (value != null) {
|
|
125
|
-
requestInit.body.append(key, value);
|
|
126
|
+
requestInit.body.append(key, (0, utils_js_2.isBlob)(value) ? value : value.toString());
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
}
|
package/cjs/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.asyncIterationUntilReturn = void 0;
|
|
3
|
+
exports.isBlob = exports.asyncIterationUntilReturn = void 0;
|
|
4
4
|
const server_1 = require("@whatwg-node/server");
|
|
5
5
|
function asyncIterationUntilReturn(iterable, callback) {
|
|
6
6
|
const iterator = iterable[Symbol.iterator]();
|
|
@@ -28,3 +28,7 @@ function asyncIterationUntilReturn(iterable, callback) {
|
|
|
28
28
|
return iterate();
|
|
29
29
|
}
|
|
30
30
|
exports.asyncIterationUntilReturn = asyncIterationUntilReturn;
|
|
31
|
+
function isBlob(value) {
|
|
32
|
+
return value.arrayBuffer !== undefined;
|
|
33
|
+
}
|
|
34
|
+
exports.isBlob = isBlob;
|
|
@@ -2,6 +2,7 @@ import { stringify as qsStringify } from 'qs';
|
|
|
2
2
|
import { fetch, FormData } from '@whatwg-node/fetch';
|
|
3
3
|
import { iterateAsyncVoid } from '@whatwg-node/server';
|
|
4
4
|
import { EMPTY_OBJECT } from '../plugins/utils.js';
|
|
5
|
+
import { isBlob } from '../utils.js';
|
|
5
6
|
import { createClientTypedResponsePromise } from './clientResponse.js';
|
|
6
7
|
const qsOptions = {
|
|
7
8
|
indices: false,
|
|
@@ -118,7 +119,7 @@ export function createClient({ endpoint, fetchFn = fetch, plugins = [], globalPa
|
|
|
118
119
|
for (const key in formDataBody) {
|
|
119
120
|
const value = formDataBody[key];
|
|
120
121
|
if (value != null) {
|
|
121
|
-
requestInit.body.append(key, value);
|
|
122
|
+
requestInit.body.append(key, isBlob(value) ? value : value.toString());
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
}
|
package/esm/utils.js
CHANGED
package/package.json
CHANGED
package/typings/utils.d.cts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare function asyncIterationUntilReturn<TInput, TOutput>(iterable: Iterable<TInput>, callback: (result: TInput) => Promise<TOutput | undefined> | TOutput | undefined): Promise<TOutput | undefined> | TOutput | undefined;
|
|
2
|
+
export declare function isBlob(value: any): value is Blob;
|
package/typings/utils.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export declare function asyncIterationUntilReturn<TInput, TOutput>(iterable: Iterable<TInput>, callback: (result: TInput) => Promise<TOutput | undefined> | TOutput | undefined): Promise<TOutput | undefined> | TOutput | undefined;
|
|
2
|
+
export declare function isBlob(value: any): value is Blob;
|