Skip to content

feat: support a way to override fetching behavior #108

@nathanchase

Description

@nathanchase

What's the best way to cache responses with ohmyfetch via an LRU cache?

With axios, I've used axios-extensions's "cacheAdapterEnhancer" like so:

import { cacheAdapterEnhancer } from 'axios-extensions';
import LRU from 'lru-cache';
const ONE_HOUR = 1000 * 60 * 60;
const defaultCache = new LRU({ maxAge: ONE_HOUR });
const defaults = $axios.defaults;
defaults.adapter = cacheAdapterEnhancer(defaults.adapter, {
  enabledByDefault: false,
  cacheFlag: 'useCache',
  defaultCache,
});

which caches responses when I explicitly add useCache: true to the request.

Is there a similar enhancer for ohmyfetch, or one planned, or an example of how to implement caching with ohmyfetch?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions