Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
js code to subscribe to stream
var source = new EventSource("{{ url_for('sse.stream') }}");
source.addEventListener('publish', function(event) {
var data = JSON.parse(event.data);
console.log("The server says " + data.message);
}, false);
source.addEventListener('error', function(event) {
console.log("Error"+ event)
alert("Failed to connect to event stream. Is Redis running?");
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment