
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
create-fetcher
Advanced tools
create-fetcher is a remote data fetching library, providing common features - configurable caching, retry, polling with both promised-based API and react hooks.
npm i --save create-fetcher
create-fetcher is built around the standard fetch(), the goal of this library is not trying to replace fetch(), but to provide common utilities around the remote data fetching:
maxAge, minFreshCache interfaceuseSWR(), usePolling(), usePaginationList()fetcher: object instance that responsible for making fetch calls, the reason it is need to be a object is for concurrency control// quick start
import { useSWR } from 'create-fetcher/lib/hooks';
function MyComponent1() {
// send request by useSWR
const { data } = useSWR('https://jsonplaceholder.typicode.com/todos/1');
return (<div>{JSON.stringify(data)}</div>);
}
// create the fetcher instance to gain more control on cache and fetcher options
import { createFetcher } from 'create-fetcher';
import { useSWR } from 'create-fetcher/lib/hooks';
// create the fetcher instance, pass signal to fetch so it supports fully abort() the request
// otherwise calling abort() on `fetcher.fetch()` returns only aborts at application side (ignores request result).
const userInfoFetcher = createFetcher((id, { signal }) => fetch(`/api/v1/users/${id}`, { signal }), { cacheMaxAge: 7200 });
function MyComponent2() {
// send request by useSWR with 1 as the id, and get the fetch result
const { data } = useSWR(userInfoFetcher, 1);
return (<div>{JSON.stringify(data)}</div>);
}
Please check out example project(react) for a usage demo.
createFetcher(url, options): create a fetcher instancecreateFetcher(requestCreator, options): create a fetcher instanceuseSWR(url, request, options), useSWR(fetcher, request, options): basic request hook that supports caching, retry on failureusePolling(url, pollingWaitTime, request, options), usePolling(fetcher, pollingWaitTime, request, options): polling request hookusePaginationList(fetcher, dataHandler, initialRequest, options): for making pagination list request calls and merges the results into a single listuseDeepEqualMemo(value), useShallowEqualMemo(value): for keep using previous value instance if new value equals with previous valuecreateMemoryCache(): in-memory cachecreateLocalStorageCache(keyPrefix, useMemoryCache): use localStorage as cache storecreateAsyncStorageCache(keyPrefix, useMemoryCache): for react-native, use AsyncStorage as cache storeforEachResponse(requestReturn, handler): callback for each request response, including response retrived from cachegetFinalResponse(requestReturn): get the final responsegetInitialResponse(requestReturn): get thee first valid response, including response retrived from cachefallbackToPureFetch(fetcher): turn fetcher into a pure fetch functionclearCache(cache, maxAge): clear expired items from cacheFAQs
customizable data fetcher wrapper for remote data fetching
The npm package create-fetcher receives a total of 4 weekly downloads. As such, create-fetcher popularity was classified as not popular.
We found that create-fetcher demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.