work on getting close to refactor
This commit is contained in:
parent
8550b1de57
commit
a63ccc96f5
15 changed files with 129 additions and 178 deletions
|
|
@ -3,6 +3,8 @@
|
|||
* Drop-in replacement for native fetch with logging support
|
||||
*/
|
||||
|
||||
// import { RequestInfo, RequestInit, Response } from '@types/bun';
|
||||
|
||||
export function fetch(
|
||||
input: RequestInfo | URL,
|
||||
init?: RequestInit & { logger?: any }
|
||||
|
|
@ -10,8 +12,10 @@ export function fetch(
|
|||
const logger = init?.logger || console;
|
||||
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
|
||||
const method = init?.method || 'GET';
|
||||
const headers = init?.headers || {};
|
||||
const proxy = init?.proxy || null;
|
||||
|
||||
logger.debug('HTTP request', { method, url });
|
||||
logger.debug('HTTP request', { method, url, headers });
|
||||
|
||||
return globalThis.fetch(input, init).then(response => {
|
||||
logger.debug('HTTP response', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue