Skip to content

Commit a70449c

Browse files
authored
fix: allow custom headers per request on fetch() (#5)
1 parent 5f563e3 commit a70449c

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@makehq/sdk",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "Make TypeScript SDK",
55
"license": "MIT",
66
"author": "Make",

src/make.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export class Make {
190190
'user-agent': `MakeTypeScriptSDK/${VERSION}`,
191191
...this.headers,
192192
authorization: `${isAPIKey(this.#token) ? 'Token' : 'Bearer'} ${this.#token}`,
193+
...options?.headers,
193194
},
194195
};
195196

test/make.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,14 @@ describe('Make SDK', () => {
5050

5151
expect(await makeWithCustomHeaders.users.me()).toBe(null);
5252
});
53+
54+
it('Should allow passing custom headers per request', async () => {
55+
const makeWithCustomHeaders = new Make(MAKE_API_KEY, MAKE_ZONE, { headers: { 'x-custom-header': 'FooBar' } });
56+
mockFetch('GET https://make.local/api/v2/users/me', { authUser: null }, req => {
57+
expect(req.headers.get('x-custom-header')).toBe('FooBar');
58+
expect(req.headers.get('x-custom-header-2')).toBe('CustomValue');
59+
});
60+
61+
await makeWithCustomHeaders.fetch('/users/me', { headers: { 'x-custom-header-2': 'CustomValue' } });
62+
});
5363
});

0 commit comments

Comments
 (0)