Add support for credentials in fetcher

This commit is contained in:
TPN 2024-06-25 13:33:52 +05:30
parent 9152184b00
commit d465789b99
No known key found for this signature in database
GPG key ID: 40AE091637892B91
4 changed files with 5 additions and 0 deletions

View file

@ -39,6 +39,7 @@ export function makeFetcher(fetcher: Fetcher): UseableFetcher {
baseUrl: ops?.baseUrl ?? '',
readHeaders: ops?.readHeaders ?? [],
body: ops?.body,
credentials: ops?.credentials,
});
};
const output: UseableFetcher = async (url, ops) => (await newFetcher(url, ops)).body;

View file

@ -7,6 +7,7 @@ export type FetchOps = {
headers: Record<string, string>;
method: string;
body: any;
credentials?: 'include' | 'same-origin' | 'omit';
};
export type FetchHeaders = {

View file

@ -28,6 +28,7 @@ export function makeStandardFetcher(f: FetchLike): Fetcher {
...ops.headers,
},
body: seralizedBody.body,
credentials: ops.credentials,
});
let body: any;

View file

@ -7,6 +7,7 @@ export type FetcherOptions = {
method?: 'HEAD' | 'GET' | 'POST';
readHeaders?: string[];
body?: Record<string, any> | string | FormData | URLSearchParams;
credentials?: 'include' | 'same-origin' | 'omit';
};
// Version of the options that always has the defaults set
@ -18,6 +19,7 @@ export type DefaultedFetcherOptions = {
query: Record<string, string>;
readHeaders: string[];
method: 'HEAD' | 'GET' | 'POST';
credentials?: 'include' | 'same-origin' | 'omit';
};
export type FetcherResponse<T = any> = {