fetch function when instantiating the client, which can be used to inspect or alter the Request or Response before/after each request.
Custom fetch function
Provide a customfetch implementation to intercept all HTTP requests:
Logging requests and responses
You can use the customfetch function to log all API interactions:
Debug mode
If you set aDEBUG=true environment variable, this library will log all requests and responses automatically:
Request and response inspection
Use the customfetch function to inspect headers, modify requests, or handle responses:
Using alternative fetch implementations
By default, this library usesnode-fetch in Node, and expects a global fetch function in other environments.
If you would prefer to use a global, web-standards-compliant fetch function even in a Node environment (for example, if you are running Node with --experimental-fetch or using NextJS which polyfills with undici), add the following import before your first import from "cloudflare":
import "cloudflare/shims/node" (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for
Response.