fetch-periodic-sync
v1.1.5
Published
fetch() a URL periodically, with caching & data-saving support.
Downloads
7
Readme
fetch-periodic-sync
fetch()
a URL periodically, with caching & data-saving support.
Installation
npm install fetch-periodic-sync
Usage
const syncViaPeriodicFetch = require('fetch-periodic-sync')
const synced = syncViaPeriodicFetch('https://wikipedia.org/', {
interval: 5_000,
})
synced.on('error', (err) => {
console.error('failed to refresh Wikipedia', err)
})
synced.on('change', (res) => {
// res is a Fetch API Response
// https://developer.mozilla.org/en-US/docs/Web/API/Response
res.text().then(console.log)
})
Contributing
If you have a question or need support using fetch-periodic-sync
, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, use the issues page.