Skip to content

Commit f4e1506

Browse files
committed
Use undici FormData
1 parent 1bedc7d commit f4e1506

4 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/http/apiCore.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { logger } from "@/logger.js";
2-
import { request, Dispatcher } from "undici";
2+
import { request, Dispatcher, FormData } from "undici";
33
import { InputSource, PageOptions, LocalInputSource } from "@/input/index.js";
44

55
export const TIMEOUT_SECS_DEFAULT: number = 120;
@@ -10,7 +10,7 @@ export interface RequestOptions {
1010
method: any;
1111
timeoutSecs: number;
1212
headers: any;
13-
body?: any;
13+
body?: FormData | string;
1414
}
1515

1616
export interface BaseHttpResponse {
@@ -40,17 +40,16 @@ export async function sendRequestAndReadResponse(
4040
options: RequestOptions,
4141
): Promise<BaseHttpResponse> {
4242
const url: string = `https://${options.hostname}${options.path}`;
43-
logger.debug(`${options.method}: ${url}`);
4443

44+
logger.debug(`${options.method}: ${url}`);
4545
const response = await request(
4646
url,
4747
{
4848
method: options.method,
4949
headers: options.headers,
5050
headersTimeout: options.timeoutSecs * 1000,
5151
body: options.body,
52-
throwOnError: false,
53-
dispatcher: dispatcher
52+
dispatcher: dispatcher,
5453
}
5554
);
5655
logger.debug("Parsing the response ...");

src/v1/http/endpoint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { URLSearchParams } from "url";
2+
import { FormData } from "undici";
23
import { InputSource, LocalInputSource } from "@/input/index.js";
34
import { StringDict } from "@/parsing/stringDict.js";
45
import {

src/v1/http/workflowEndpoint.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { URLSearchParams } from "url";
2+
import { FormData } from "undici";
23
import { InputSource, LocalInputSource } from "@/input/index.js";
34
import { ExecutionPriority } from "@/v1/parsing/common/index.js";
45
import {

src/v2/client/baseParameters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FormData } from "undici";
12
import { MindeeConfigurationError } from "@/errors/index.js";
23

34
/**

0 commit comments

Comments
 (0)