Basically library structure

This commit is contained in:
mrjvs
2023-08-23 20:07:39 +02:00
parent fe721bee37
commit ef766936dd
12 changed files with 191 additions and 29 deletions

15
src/fetchers/common.ts Normal file
View File

@@ -0,0 +1,15 @@
import { FetcherOptions } from '@/fetchers/types';
// make url with query params and base url used correctly
export function makeFullUrl(url: string, ops?: FetcherOptions): string {
// glue baseUrl and rest of url together
const fullUrl = ops?.baseUrl ?? '';
// TODO make full url
const parsedUrl = new URL(fullUrl);
Object.entries(ops?.query ?? {}).forEach(([k, v]) => {
parsedUrl.searchParams.set(k, v);
});
return parsedUrl.toString();
}