pollrdeprecated

A JavaScript/AJAX polling engine.

Usage no npm install needed!

<script type="module">
  import pollr from 'https://cdn.skypack.dev/pollr';
</script>

README

pollr

A JavaScript/AJAX polling engine.

Usage

import Pollr from 'pollr';

var pollr = new Pollr({
  url: '/test',
  retries: 10,
  interval: 3000,
  responseType: 'json'
});

pollr.on('data', function(data) {
  if (data.foo === 'bar') {
    // Do something awesome
    pollr.stop(); 
  }
});

pollr.on('error', function(error) {
  console.error(error); // Called when response.statusCode != 200
});

pollr.start(); // Polls the server 11 times, unless stopped

Other Examples

Continuous polling

pollr.retries = null; 
pollr.start(); // Will poll until stopped

Post data

pollr.method = 'post';
pollr.data = { message: 'Is anybody home...?' };

Contact

AJ Bond

  • Email: olishmollie@gmail.com
  • Twitter: @olishmollie