Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: DO-3034 make request() utility options argument optional, defaulting to empty object like fetch #380

Merged
merged 5 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/dara-core/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
title: Changelog
---

## NEXT

- Internal (JS): make request() helper options default to empty object

## 1.14.0

- Added support for seamless token refresh mechanism. A provided auth config can be configured to support token refresh by:
Expand Down
7 changes: 3 additions & 4 deletions packages/dara-core/js/api/http.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ export class RequestExtrasSerializable {
* Light wrapper around fetch.
*
* @param url URL
* @param options fetch options
* @param extras request extras to be merged into the options
* @param options optional fetch options. Multiple option sets can be provided, they will be merged in order with later options overriding earlier ones.
*/
export async function request(url: string | URL, options: RequestInit, extras?: RequestExtras): Promise<Response> {
export async function request(url: string | URL, ...options: RequestInit[]): Promise<Response> {
// block on the token in case it's locked, i.e. being refreshed by another concurrent request
const sessionToken = await globalStore.getValue(getTokenKey());
const mergedOptions = extras ? { ...options, ...extras } : options;
const mergedOptions = options.reduce((acc, opt) => ({ ...acc, ...opt }), {});

const { headers, ...other } = mergedOptions;

Expand Down
Loading