From 85140a0c56fcf050a9747604bb401626ce5f985b Mon Sep 17 00:00:00 2001 From: Alex Cheshire Date: Mon, 31 Mar 2025 16:22:46 +0100 Subject: [PATCH] Allow override values for got request options --- src/client.ts | 3 ++- src/types.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/client.ts b/src/client.ts index 508326e..5b4bf8d 100644 --- a/src/client.ts +++ b/src/client.ts @@ -70,7 +70,7 @@ export default class NetsuiteApiClient { * @returns */ public async request(opts: NetsuiteRequestOptions) { - const { path = "*", method = "GET", body = "", heads = {}, restletUrl } = opts; + const { path = "*", method = "GET", body = "", heads = {}, restletUrl, overrides = {} } = opts; const cleanPath = removeLeadingSlash(path); // Set up the Request URI @@ -91,6 +91,7 @@ export default class NetsuiteApiClient { headers: this.getAuthorizationHeader(uri, method), throwHttpErrors: true, decompress: true, + ...overrides, } as OptionsOfTextResponseBody; if (Object.keys(heads).length > 0) { diff --git a/src/types.ts b/src/types.ts index e34f0a8..824970c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,4 @@ +import { OptionsOfTextResponseBody } from "got"; import type {Buffer} from "node:buffer"; import type {Readable} from "node:stream"; @@ -23,6 +24,10 @@ type BaseRequestOptions = { * Additional headers to send with the request */ heads?: any; + /** + * These will override the options that are passed to the request library + */ + overrides?: OptionsOfTextResponseBody }; export type NetsuiteRequestOptions =