Skip to content

Commit e6c215a

Browse files
chore(internal): codegen related update (#80)
1 parent b938f98 commit e6c215a

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

src/core.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export abstract class APIClient {
163163
maxRetries = 2,
164164
timeout = 60000, // 1 minute
165165
httpAgent,
166-
fetch: overriddenFetch,
166+
fetch: overridenFetch,
167167
}: {
168168
baseURL: string;
169169
maxRetries?: number | undefined;
@@ -176,7 +176,7 @@ export abstract class APIClient {
176176
this.timeout = validatePositiveInteger('timeout', timeout);
177177
this.httpAgent = httpAgent;
178178

179-
this.fetch = overriddenFetch ?? fetch;
179+
this.fetch = overridenFetch ?? fetch;
180180
}
181181

182182
protected authHeaders(opts: FinalRequestOptions): Headers {
@@ -522,19 +522,9 @@ export abstract class APIClient {
522522

523523
const timeout = setTimeout(() => controller.abort(), ms);
524524

525-
const fetchOptions = {
526-
signal: controller.signal as any,
527-
...options,
528-
};
529-
if (fetchOptions.method) {
530-
// Custom methods like 'patch' need to be uppercased
531-
// See https://github.com/nodejs/undici/issues/2294
532-
fetchOptions.method = fetchOptions.method.toUpperCase();
533-
}
534-
535525
return (
536526
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
537-
this.fetch.call(undefined, url, fetchOptions).finally(() => {
527+
this.fetch.call(undefined, url, { signal: controller.signal as any, ...options }).finally(() => {
538528
clearTimeout(timeout);
539529
})
540530
);

tests/index.test.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,6 @@ describe('instantiate client', () => {
122122
expect(spy).toHaveBeenCalledTimes(1);
123123
});
124124

125-
test('normalized method', async () => {
126-
let capturedRequest: RequestInit | undefined;
127-
const testFetch = async (url: RequestInfo, init: RequestInit = {}): Promise<Response> => {
128-
capturedRequest = init;
129-
return new Response(JSON.stringify({}), { headers: { 'Content-Type': 'application/json' } });
130-
};
131-
132-
const client = new Browserbase({
133-
baseURL: 'http://localhost:5000/',
134-
apiKey: 'My API Key',
135-
fetch: testFetch,
136-
});
137-
138-
await client.patch('/foo');
139-
expect(capturedRequest?.method).toEqual('PATCH');
140-
});
141-
142125
describe('baseUrl', () => {
143126
test('trailing slash', () => {
144127
const client = new Browserbase({ baseURL: 'http://localhost:5000/custom/path/', apiKey: 'My API Key' });
@@ -194,7 +177,7 @@ describe('instantiate client', () => {
194177
expect(client.apiKey).toBe('My API Key');
195178
});
196179

197-
test('with overridden environment variable arguments', () => {
180+
test('with overriden environment variable arguments', () => {
198181
// set options via env var
199182
process.env['BROWSERBASE_API_KEY'] = 'another My API Key';
200183
const client = new Browserbase({ apiKey: 'My API Key' });

0 commit comments

Comments
 (0)