I am using express to render a page with some html that is built from information pulled from an eventEmitter.
Essentially the code right now is something like this:
app.post("/login", (req, res) => {
let factory = eventFactory(args);
let client = factory.client();
let html;
client.once(client.Event.Ready, function() {
html = buildHTML(someArgs);
res.render("page", {html: html});
})
}
This draws it fine once. However, I'd like to have the page redraw upon new events. I know I could use client.on()
for firing this callback upon each received event, however I don't believe just changing that will push anything down to the client.
I tried a simple http-meta
tag for refreshes on the client side of the app but I get errors saying cannot GET /login
when it refreshes.
So I think my design is probably incorrect here. Looking for tips and/or advice on how to approach or design this so that the client gets updated information upon an event received from the event handler. Is the only way to do this to use AJAX or websockets?
Thank You