Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/fetch-periodic-sync
fetch() a URL periodically, with caching & data-saving support.
https://github.com/derhuerst/fetch-periodic-sync
Last synced: 5 days ago
JSON representation
fetch() a URL periodically, with caching & data-saving support.
- Host: GitHub
- URL: https://github.com/derhuerst/fetch-periodic-sync
- Owner: derhuerst
- License: isc
- Created: 2020-12-16T21:40:28.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-18T22:40:34.000Z (over 2 years ago)
- Last Synced: 2024-10-03T23:54:12.094Z (about 1 month ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# fetch-periodic-sync
**[`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) a URL periodically, with caching & data-saving support.**
[![npm version](https://img.shields.io/npm/v/fetch-periodic-sync.svg)](https://www.npmjs.com/package/fetch-periodic-sync)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/fetch-periodic-sync.svg)
![minimum Node.js version](https://img.shields.io/node/v/fetch-periodic-sync.svg)
[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)## Installation
```shell
npm install fetch-periodic-sync
```## Usage
```js
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](https://github.com/derhuerst/fetch-periodic-sync/issues).