TL;DR - Using ejs and express.js, how to render a page with default/empty variable values first before doing polling/interrupt to get the calculated variable values, possibly after 10 seconds or more.
Hi, I am new at making server-side webpages (have experience with automated client-side webapps) and found embedded js (ejs) along with express.js to be exactly what I needed for my website integrated with discord bot
I have figured out how to set it up, and it is indeed looking beautiful.
However, the problem is that I am sending variables to my ejs page (through
response.render(...)) and getting the values of these variables take more than 10 seconds (it could be up to 200 function calls or more to get the array values). Thus this latency of over 10 seconds reflects how slow the
render() is for me.
I have tried rendering my page twice inside the
.get() HTTP method and encountered an error, and rightly so since I’m sending 2 headers for 1 http request (or so I learned from the web). Some person said express.js is designed this way and I’ll have to modify express’
send() method and
.end() method - this is too complicated for me.
Another person made a suggestion to render the page and then poll for values back from server. He didn’t mention on how to do this poll and communicate with the server though. And I admit that I have no idea on how to have a poll or interrupt to pass the finalised variable values to the webpage.
Any solutions above or any new solutions are much appreciated. Thank you in advance