Hacker News new | ask | show | jobs
Show HN: Kool-Fetch – A Lightweight Fetch Wrapper with Axios-Like Interceptors (github.com)
1 points by webzz 302 days ago
Hey HN,

I’m excited to share kool-fetch, a lightweight (~8kb, 0 dependencies) fetch wrapper I built to simplify HTTP requests in JavaScript. It brings axios-like request and response interceptors to the native fetch API, cutting down on boilerplate code.

Key features:

- Interceptors: Modify requests (e.g., add auth headers) or responses (e.g., handle 401 errors) with ease. - Response Unwrapping: Simplify parsing with .unwrap("json") for typed JSON, text, or arrayBuffer. - Customizable Error Handling: Throw on HTTP errors with custom error messages. - Native Fetch Compatibility: Use it like fetch, with optional baseURL and default configs.