Last active
March 22, 2019 09:02
-
-
Save karenpeng/79e6c70db79bd1ee73cf772d9c168ce9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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