forked from mystiq/hydrogen-web
Remove length property
This commit is contained in:
parent
49a56efa82
commit
d6378133d8
1 changed files with 2 additions and 5 deletions
|
@ -20,7 +20,6 @@ import {BlobHandle} from "../../platform/web/dom/BlobHandle.js";
|
||||||
export type EncodedBody = {
|
export type EncodedBody = {
|
||||||
mimeType: string;
|
mimeType: string;
|
||||||
body: BlobHandle | string;
|
body: BlobHandle | string;
|
||||||
length: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function encodeQueryParams(queryParams?: Record<string, any>): string {
|
export function encodeQueryParams(queryParams?: Record<string, any>): string {
|
||||||
|
@ -40,15 +39,13 @@ export function encodeBody(body: BlobHandle | Record<string, any>): EncodedBody
|
||||||
const blob = body as BlobHandle;
|
const blob = body as BlobHandle;
|
||||||
return {
|
return {
|
||||||
mimeType: blob.mimeType,
|
mimeType: blob.mimeType,
|
||||||
body: blob, // will be unwrapped in request fn
|
body: blob // will be unwrapped in request fn
|
||||||
length: blob.size
|
|
||||||
};
|
};
|
||||||
} else if (typeof body === "object") {
|
} else if (typeof body === "object") {
|
||||||
const json = JSON.stringify(body);
|
const json = JSON.stringify(body);
|
||||||
return {
|
return {
|
||||||
mimeType: "application/json",
|
mimeType: "application/json",
|
||||||
body: json,
|
body: json
|
||||||
length: json.length
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Unknown body type: " + body);
|
throw new Error("Unknown body type: " + body);
|
||||||
|
|
Loading…
Reference in a new issue