A lightweight HTTP request library for JavaScript, wrapping the Fetch API with middleware-like hooks (onLoading, onLoaded, onBefore, onAfter, onOther, onProgress) and support for cancelable requests via HotPromise. Version 0.5.4 is stable, with irregular releases. Key differentiators: integrates with UI loading states out of the box, provides a clean ajaxFn factory pattern for reusable defaults, and handles form-data/json request types including a special mixed mode for POST. Alternatives like axios are more feature-rich but wya-fetch focuses on simplicity and hook-based customization.
npm install wya-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create an ajaxFn instance with default hooks, perform GET and POST requests with cancellation.
Update calls to ajaxFn to pass defaultOptions as an object: ajaxFn({ onLoading: ... }) instead of using separate setup.Change import from 'import MyFetch from "wya-fetch"' to 'import { ajaxFn } from "wya-fetch"' and use ajaxFn to create instance.Use requestType: 'json' and the library will stringify the param object for you. The fetch will set Content-Type to application/json.
Check if the promise is pending before cancelling, or wrap cancel in try/catch.
Refer to CHANGELOG or source code to check if onProgress is still supported.
Ensure you are using a JavaScript bundler that supports ES modules (webpack, rollup, vite) and that the package version is at least 0.3.0. Try: import { ajaxFn } from 'wya-fetch';Check the URL format and ensure the server supports CORS. For local development, use a proxy or server with correct headers.
Ensure that after creating ajax = ajaxFn(), you call ajax(options) to make a request.
No dependency data recorded yet.