Closed liegeandlief closed 1 year ago
Hey @liegeandlief,
Is it possible to pass the fetch implementation to wretch?
Absolutely, you can use the polyfills methods to pass a custom fetch implementation in a global or scoped way.
An example of where this would be useful is in SvelteKit load functions where fetch is passed into the function as an argument.
The non-global way might be what you are looking for:
export async function load({ fetch, params }) {
const item = await wretch(`/api/items/${params.id}`).polyfills({ fetch }).get().json();
return { item };
}
That's brilliant, thank you!
Is it possible to pass the fetch implementation to wretch? If not I think this could be really helpful. It could be part of the ‘options’ object maybe.
An example of where this would be useful is in SvelteKit load functions where fetch is passed into the function as an argument.