refactor: update json return type to JSON and format function parameters

This commit is contained in:
Flummi 2025-03-18 11:36:17 +01:00
parent 6fad46fd95
commit 08b74ec61b

View File

@ -7,7 +7,7 @@ type ResponseData = {
body: http.IncomingMessage;
headers: http.IncomingHttpHeaders;
text: () => Promise<string>;
json: () => Promise<any>;
json: () => Promise<JSON>;
buffer: () => Promise<Buffer>;
arrayBuffer: () => Promise<ArrayBuffer>;
};
@ -43,7 +43,10 @@ const readData = (
.on("error", reject);
});
export default async (urlString: string, options: ExtendedRequestOptions = {}): Promise<ResponseData> => {
export default async (
urlString: string,
options: ExtendedRequestOptions = {}
): Promise<ResponseData> => {
const { protocol, hostname, pathname, search, port } = new URL(urlString);
const body =