mirror of
https://github.com/sussy-code/providers.git
synced 2026-04-13 21:20:18 +00:00
Add support for credentials in fetcher
This commit is contained in:
parent
9152184b00
commit
d465789b99
4 changed files with 5 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export type FetchOps = {
|
|||
headers: Record<string, string>;
|
||||
method: string;
|
||||
body: any;
|
||||
credentials?: 'include' | 'same-origin' | 'omit';
|
||||
};
|
||||
|
||||
export type FetchHeaders = {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ export function makeStandardFetcher(f: FetchLike): Fetcher {
|
|||
...ops.headers,
|
||||
},
|
||||
body: seralizedBody.body,
|
||||
credentials: ops.credentials,
|
||||
});
|
||||
|
||||
let body: any;
|
||||
|
|
|
|||
|
|
@ -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> = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue