Skip to content

Instantly share code, notes, and snippets.

@karenpeng
Last active March 22, 2019 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karenpeng/79e6c70db79bd1ee73cf772d9c168ce9 to your computer and use it in GitHub Desktop.
Save karenpeng/79e6c70db79bd1ee73cf772d9c168ce9 to your computer and use it in GitHub Desktop.
import { fetchUrl } from 'fetch';
const registerLongPolling = () => {
let counter = 0;
fetchUrl('http://localhost:3000/longpolling', (error, meta, body) => {
if (error) {
return;
}
if (counter > 4) {
return;
}
setTimeout(() => {
registerLongPolling();
counter++;
}, 1000);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment