api-poll

1.0.1 • Public • Published

API Poller

An event driven external API poller designed for real-time applications.

Documentation is in the JSDocs.

Example

const Poller = require('api-poll')
 
const endpoint = 'https://cat-fact.herokuapp.com/facts/random?animal=cat&amount=1'
const randomFact = new Poller(endpoint, {
    repeat: 2000, //ms
    variance: {
        min: 200, //ms
        max: 2500 //ms
    },
    // variance: true,
    fetchHeaders: {
        "Origin": "example.com"
    }
})
 
randomFact
    .start()
    .on('data', data => console.log('got new data: ', data))
 
setTimeout(randomFact.stop, 20000)

Package Sidebar

Install

npm i api-poll

Weekly Downloads

31

Version

1.0.1

License

ISC

Unpacked Size

5.77 kB

Total Files

4

Last publish

Collaborators

  • luc.io