How to return the data requested by https.request in nodejs to the front end?

clipboard.png
use the third-party SMS platform, use the request of https.request, and the returned data is in resq.on. I want to return the data returned by the third party directly to the front end, and then the front end uses the content returned by the third-party platform to judge, but the data can"t be returned all the time. Please take a look at it and kneel down.

Mar.22,2021
The

problem has been solved. Add a callback function to post, and then you can return


. At this time, node is actually equivalent to a proxy. It first receives the request (req1, res1) from the browser, and then establishes a connection request (req2) with the third-party SMS platform. The data obtained through req2 needs to be sent to the front-end browser using res1.write.

Menu