Render A Loader Page While Continuing The Request

I am currently developing an application that is using nodejs and ejs along with the shopify api. I wanted to know if there is a way by which we can render a spinner/loader on the screen while the request gets completed.

I mean something like:

app.get('/', (req, res) => {
  // continue the api authentication

is there any possible way to do so.



I see you are using server side rendering, which returns html to be shown on server itself.

Showing spinner is only possible on already loaded UI where subsequent requests only get data and insert it back on your UI. As you have the page already loaded you can start and stop showing a loader on your screen.

If you are trying to load completely a new page in you request it wont be possible.

Solutions :

1) Use a SPA architecture. 2) From your node server return the compiled html from server as a response to ajax request and insert it by yourself on UI, that way you have an already loaded page where you can show a spinner. You will have to get compiled html on server itself and send back html as encoded string, decode it back on UI and insert.