Skip to content

Instantly share code, notes, and snippets.

Created June 17, 2020 05:49
What would you like to do?
js code to subscribe to stream
var source = new EventSource("{{ url_for('') }}");
source.addEventListener('publish', function(event) {
var data = JSON.parse(;
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