mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 15:33:26 +00:00
Basically library structure
This commit is contained in:
15
src/fetchers/standardFetch.ts
Normal file
15
src/fetchers/standardFetch.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { makeFullUrl } from '@/fetchers/common';
|
||||
import { Fetcher } from '@/fetchers/types';
|
||||
|
||||
export function makeStandardFetcher(f: typeof fetch): Fetcher {
|
||||
const normalFetch: Fetcher = (url, ops) => {
|
||||
const fullUrl = makeFullUrl(url, ops);
|
||||
|
||||
return f(fullUrl, {
|
||||
method: ops.method,
|
||||
body: JSON.stringify(ops.body), // TODO content type headers + proper serialization
|
||||
});
|
||||
};
|
||||
|
||||
return normalFetch;
|
||||
}
|
Reference in New Issue
Block a user