How to monkey patch fetch?
Answered
Red-throated Loon posted this in #help-forum
Red-throated LoonOP
I'm using pages router and I've tried adding this in multiple places (
The library that I'm speaking of, that triggers fetch requests, is
_document, next.config.js, getServerSideProps) but it looks like third party library that make fetch requests doesn't use my function.const _fetch = fetch
fetch = async function (...args: Parameters<typeof _fetch>) {
return myFetchFunc.apply(this, [...args, _fetch])
}The library that I'm speaking of, that triggers fetch requests, is
next-drupal and it is using fetch apiAnswered by Red-throated Loon
Nvm, it looks like next-drupal allows setting a custom fetcher as an option to the client https://github.com/chapter-three/next-drupal/blob/main/packages/next-drupal/src/next-drupal-base.ts#L207-L211
1 Reply
Red-throated LoonOP
Nvm, it looks like next-drupal allows setting a custom fetcher as an option to the client https://github.com/chapter-three/next-drupal/blob/main/packages/next-drupal/src/next-drupal-base.ts#L207-L211
Answer