mirror of
https://github.com/sussy-code/providers.git
synced 2026-04-21 08:31:57 +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 ?? '',
|
baseUrl: ops?.baseUrl ?? '',
|
||||||
readHeaders: ops?.readHeaders ?? [],
|
readHeaders: ops?.readHeaders ?? [],
|
||||||
body: ops?.body,
|
body: ops?.body,
|
||||||
|
credentials: ops?.credentials,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const output: UseableFetcher = async (url, ops) => (await newFetcher(url, ops)).body;
|
const output: UseableFetcher = async (url, ops) => (await newFetcher(url, ops)).body;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export type FetchOps = {
|
||||||
headers: Record<string, string>;
|
headers: Record<string, string>;
|
||||||
method: string;
|
method: string;
|
||||||
body: any;
|
body: any;
|
||||||
|
credentials?: 'include' | 'same-origin' | 'omit';
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FetchHeaders = {
|
export type FetchHeaders = {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ export function makeStandardFetcher(f: FetchLike): Fetcher {
|
||||||
...ops.headers,
|
...ops.headers,
|
||||||
},
|
},
|
||||||
body: seralizedBody.body,
|
body: seralizedBody.body,
|
||||||
|
credentials: ops.credentials,
|
||||||
});
|
});
|
||||||
|
|
||||||
let body: any;
|
let body: any;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export type FetcherOptions = {
|
||||||
method?: 'HEAD' | 'GET' | 'POST';
|
method?: 'HEAD' | 'GET' | 'POST';
|
||||||
readHeaders?: string[];
|
readHeaders?: string[];
|
||||||
body?: Record<string, any> | string | FormData | URLSearchParams;
|
body?: Record<string, any> | string | FormData | URLSearchParams;
|
||||||
|
credentials?: 'include' | 'same-origin' | 'omit';
|
||||||
};
|
};
|
||||||
|
|
||||||
// Version of the options that always has the defaults set
|
// Version of the options that always has the defaults set
|
||||||
|
|
@ -18,6 +19,7 @@ export type DefaultedFetcherOptions = {
|
||||||
query: Record<string, string>;
|
query: Record<string, string>;
|
||||||
readHeaders: string[];
|
readHeaders: string[];
|
||||||
method: 'HEAD' | 'GET' | 'POST';
|
method: 'HEAD' | 'GET' | 'POST';
|
||||||
|
credentials?: 'include' | 'same-origin' | 'omit';
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FetcherResponse<T = any> = {
|
export type FetcherResponse<T = any> = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue