What is the difference and connection between res.write () res.send (), res.end ()?

and in res.writeHead (200, {

)
  "Set-Cookie": "myCookie=test",
  "Content-Type": "text/plain"

});
Why can"t you use res.send () if you want to return content after setting cookie? What should I use? Also available for res.cookie ("myCookie","test",) or res.writeHead (200, {

)
  "Set-Cookie": "myCookie=test",
  "Content-Type": "text/plain"

}) Why does this way of setting cookie not take effect in the response header when the first request is made, and there is no cookie?? in the response header only when the second request is made?

May.28,2021

http.ServerResponse class
1. If you want to continue returning content after writeHead , you should call the write / end method.
2. cookie is set on the client after the first server response, so the second client request will carry cookie (personal understanding)

Menu