eventsource
eventsource copied to clipboard
Remove eventName from type declaration before emit
I tested using HackerNews firebase API, delete eventName solved my issue.
When you debug here eventName is put or open, etc. The emitter can't find listeners with that name, delete eventName and only use 'message' as type, then my code was working.
My code was
var EventSource = require("eventsource");
var eventSourceInitDict = { rejectUnauthorized: false };
var es = new EventSource(
"https://hacker-news.firebaseio.com/v0/updates.json",
eventSourceInitDict
);
es.onmessage = function (e) {
console.log(e.data);
};
es.onerror = function (err) {
console.log("ERROR!", err);
};