Add runner

This commit is contained in:
mrjvs
2023-08-27 19:47:09 +02:00
parent 59b2aa22f7
commit c55f830c30
9 changed files with 207 additions and 33 deletions

View File

@@ -1,4 +1,4 @@
import { FetcherOptions } from '@/fetchers/types';
import { Fetcher, FetcherOptions, UseableFetcher } from '@/fetchers/types';
// make url with query params and base url used correctly
export function makeFullUrl(url: string, ops?: FetcherOptions): string {
@@ -13,3 +13,15 @@ export function makeFullUrl(url: string, ops?: FetcherOptions): string {
return parsedUrl.toString();
}
export function makeFullFetcher(fetcher: Fetcher): UseableFetcher {
return (url, ops) => {
return fetcher(url, {
headers: ops?.headers ?? {},
method: ops?.method ?? 'GET',
query: ops?.query ?? {},
baseUrl: ops?.baseUrl ?? '',
body: ops?.body,
});
};
}