Answer the question
In order to leave comments, you need to log in
How to send two requests from one router?
setTimeout(()=> {
console.log('setTimeout!');
res.send('hello from setTimeout')
},2000)
res.send('hello');
Answer the question
In order to leave comments, you need to log in
the fact is that I want all rendering to be on the server side and not on the client, I want to make a request to another page to get the data and then send the ready html to the server, But I have a problem in the implementation of preloadera ... That is, i go to '/'
send ajax request to get data while request is being processed i show preloader on client like :
once request is processed in cb function i get response, form html, and send to server... this is what i want.. .but I can't implement it because of two requests in the router '/' , ... the whole idea is to render on the server...
yes, I probably will have to use websocket ..., just right now, many people write about rendering on the server side that it's fast .. . that's why it became so interesting to me res.send('preloaderOn');
Judging by the task described in the comment, you need to manage the preloader on the client, not on the server. The process of getting data from the server should look something like this:
1. The user has performed an action that requires a request to the server (or the page has just loaded and needs more data to render).
2. The client (js) shows the user a preloader and sends a request to the server.
3. The server renders what it needs and sends the result to the client.
4. The client receives the rendered data, hides the preloader and shows the result.
If this is not your case, then try to describe your case point by point, focusing on each point on who is performing the action. For example:
1. User visits "/"
2.The client sends an ajax request to the server
3. The server responds
4. The client displays the result of the request
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question