A lightweight wrapper around window.fetch that memoizes JSON responses using in-memory cache and sessionStorage for persistence. Version 1.0.0 is the latest stable release. Unlike raw fetch, it automatically parses JSON and caches results keyed by request arguments (URL, options, and an optional cache-busting token). It is designed for browser-only use, ships TypeScript type definitions, and enforces that the third argument must be a string, number, boolean, Date, null, or undefined. It differentiates by providing simple cache control without external dependencies, but lacks features like TTL, cache size limits, or error handling for non-JSON responses.
npm install memoized-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage: network request on first call, cached response on subsequent identical calls, and cache busting with a third argument.
Ensure cache-busting token is one of the allowed types.
Use only in browser contexts; consider a polyfill for fetch and storage if needed.
Ensure endpoints return JSON or handle errors with try/catch.
No action needed.
Change to 'import memoizedFetch from 'memoized-fetch''.
Ensure code runs in a browser or polyfill fetch and sessionStorage.
Pass a primitive or Date instance, or null/undefined.
Check that the endpoint returns JSON and handle non-JSON responses.
No dependency data recorded yet.