Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 429 Bytes

README.md

File metadata and controls

25 lines (16 loc) · 429 Bytes

Polling.js

Installation

npm install polling-js

Usage

import { setPolling } from 'polling-js';

const fetchUserData = (signal) => {
  return fetch('https://api.randomuser.me/', {signal})
    .then(response => response.json())
    .then(user => console.log(user));
};

const cancelPolling = setPolling(fetchUserData, 1000, new AbortController());

setTimeout(cancelPolling, 10000);

License

MIT