Skip to content

Commit

Permalink
Replace Headers by an object for params
Browse files Browse the repository at this point in the history
  • Loading branch information
fpassaniti committed Jan 2, 2024
1 parent 368f652 commit 592e22d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/api-client/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ApiClientOptions {
domain?: string;
apiKey?: string;
fetch?: WindowOrWorkerGlobalScope['fetch'];
headers?: Headers;
headers?: HeadersInit;
interceptRequest?: RequestInterceptor;
interceptResponse?: ResponseInterceptor;
hideDeprecatedWarning?: boolean;
Expand Down Expand Up @@ -75,7 +75,7 @@ function buildConfig(
if (domain) newConfig.baseUrl = computeBaseUrl(domain);
if (apiKey) newConfig.apiKey = apiKey;
if (fetch) newConfig.fetch = fetch;
if (headers) newConfig.headers = headers;
if (headers) newConfig.headers = new Headers(headers);
if (interceptRequest) newConfig.interceptRequest = interceptRequest;
if (interceptResponse) newConfig.interceptResponse = interceptResponse;
newConfig.hideDeprecatedWarning = Boolean(hideDeprecatedWarning);
Expand Down
4 changes: 2 additions & 2 deletions packages/api-client/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Api client', () => {
expect(req.headers.get('headerKey')).toEqual('headerValue');
return JSON.stringify(apiResponse);
});
const headers = new Headers({'headerKey': 'headerValue'});
const headers = {'headerKey': 'headerValue'};
const client = new ApiClient({ headers });
const response = await client.get(fromCatalog().itself());
expect(response).toEqual(apiResponse);
Expand All @@ -69,7 +69,7 @@ describe('Api client', () => {
expect(req.headers.get('Authorization')).toEqual('ApiKey 1234');
return JSON.stringify(apiResponse);
});
const headers = new Headers({'headerKey': 'headerValue'});
const headers = {'headerKey': 'headerValue'};
const client = new ApiClient({ headers, apiKey: '1234' });
const response = await client.get(fromCatalog().itself());
expect(response).toEqual(apiResponse);
Expand Down

0 comments on commit 592e22d

Please sign in to comment.