@kisaragi-hiu/cached-fetch


Tags
typescript library
Github
https://github.com/kisaragi-hiu/cached-fetch

A caching function designed for caching fetch GET responses on disk in a command line program.

I keep rewriting this logic in multiple projects, so I'm making it a package.

import { cached } from "@kisaragi-hiu/cached-fetch";

const text = await cached(
  "myCacheKey",
  () => fetch("https://example.com")
)

const text = await cached(
  "myCacheKey2",
  () => $`echo hello`
)