A client-side library that allows you to queue fetch requests.
- Supports ES modules
- Supports CommonJS
npm install @fundwave/fetchqimport { FetchQueue } from "@fundwave/fetchq";
const MyFetchQueue = new FetchQueue({ concurrent: 2 });
// returns custom fetch function with queueing enabled.
const fetch = MyFetchQueue.getFetchMethod();import { FetchQueue } from "@fundwave/fetchq";
const fetchQueue = new FetchQueue(); // concurent defaults to 3
const customFetch = fetchQueue.getFetchMethod();
const urls = [...]
const options = {...}
const promises = urls.map(async (url) => await customFetch(url, options))
const responses = await Promise.all(promises);// get queue length at real time
console.log(fetchQueue.getQueueLength());// getters and setters
fetchQueue.setConcurrent(5);
console.log(fetchedQueue.getConcurrent()); // output: 5
fetchQueue.setDebug(true);
console.log(fetchedQueue.getDebug()); // output: true// start and pause queue
const fetchQueue = new FetchQueue(concurrent: 3, pauseQueueOnInit: true);
const customFetch = fetchQueue.getFetchMethod();
// ...some calls
fetchQueue.emptyQueue();
fetchQueue.startQueue();
// ...some calls
fetchQueue.pauseQueue();Note: See DOCUMENTATION.md for more information on methods.
