JSFiddle - React, Tailwind, and code Playground
by abeisgreat
JavaScript
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (!xmlhttp.response || xmlhttp.response == "") return;
var rows = xmlhttp.response.split('\n');
var event = {};
rows.forEach(function (row) {
var key = row.slice(0, row.indexOf(':')).trim();
var value = row.slice(row.indexOf(':')+1, row.length).trim();
event[key] = value;
});
if (event.event == "put") {
alert(event.data);
}
};
xmlhttp.open('GET', 'https://bucket.firebaseio.com/flubber.json', true);
xmlhttp.setRequestHeader('Accept', 'text/event-stream');
xmlhttp.send(null);