mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 17:43:25 +00:00
fetcher seralization
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
import { serializeBody } from '@/fetchers/body';
|
||||
import { makeFullUrl } from '@/fetchers/common';
|
||||
import { Fetcher } from '@/fetchers/types';
|
||||
|
||||
@@ -7,9 +8,15 @@ export function makeStandardFetcher(f: typeof fetch): Fetcher {
|
||||
const normalFetch: Fetcher = (url, ops) => {
|
||||
const fullUrl = makeFullUrl(url, ops);
|
||||
|
||||
const seralizedBody = serializeBody(ops.body);
|
||||
|
||||
return f(fullUrl, {
|
||||
method: ops.method,
|
||||
body: JSON.stringify(ops.body), // TODO content type headers + proper serialization
|
||||
headers: {
|
||||
...seralizedBody.headers,
|
||||
...ops.headers,
|
||||
},
|
||||
body: seralizedBody.body,
|
||||
});
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user