How does express respond asynchronously when receiving http requests

  node.js, question

var app = require(‘express’)();‘/getsomething’, function(req, resp){

//operation a: request data from another place according to req (asynchronous)
 //This request cannot be answered immediately at this time.


If you want to get the current resp when operation A has a result, you can reply to this request resp.send(‘result’)

Can it be realized?

Try to press a field in req to save resp in redis and retrieve it when operation A has a result.
However, JSON.stringify(resp) failed when saving redis, converting circular structure to JSON

Ask the great god for advice

The question you asked does not hold water.
After the connection is established, the code segments are synchronized. The browser will wait for the return at this time. The Http protocol can only return the data once. It is meaningless to do asynchronous operation at this time. After executing to resp.send, the client receives the data and closes the link.

I understand what you mean a little, what you want is to give a reply after client requests, and then give a reply after having the operation later.
That’s, send data whenever you want.