Functional and immutable mixin for the Fetch API that sets a default base URL and/or default options (e.g., headers) on fetch calls. Version 1.0.0 is stable and follows semantic versioning. It does not modify input objects and supports both browser and Node.js environments when paired with a polyfill like node-fetch or fetch-off. Its key differentiator is immutability: options are merged recursively without mutation, and it does not pollute prototypes.
npm install fetch-defaultsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a customized fetch with a base URL and default Authorization header, then making a relative request.
Install and pass a fetch implementation like node-fetch or fetch-off.
If you need to merge arrays, handle that manually before passing options.
Ensure the base URL ends with a slash if you want to avoid path concatenation issues.
Consider using MIT-licensed alternatives like 'wretch' or 'redaxios' if AGPL is problematic.
Use `import fetchDefaults from 'fetch-defaults'` (ESM) or `const fetchDefaults = require('fetch-defaults')` (CommonJS).Install and import node-fetch or fetch-off before using fetchDefaults.