fetch-periodic-sync

1.1.5 • Public • Published

fetch-periodic-sync

fetch() a URL periodically, with caching & data-saving support.

npm version ISC-licensed minimum Node.js version support me via GitHub Sponsors chat with me on Twitter

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.

Readme

Keywords

Package Sidebar

Install

npm i fetch-periodic-sync

Weekly Downloads

4

Version

1.1.5

License

ISC

Unpacked Size

6.62 kB

Total Files

5

Last publish

Collaborators

  • derhuerst