Difference between response.send and response.write in node js

后端 未结 4 621
耶瑟儿~
耶瑟儿~ 2020-12-01 01:31

I have written a small API which uses the Node js \"restify\" framework. This API receives a request (actually anything after \"/\") and then send that request to another se

4条回答
  •  我在风中等你
    2020-12-01 01:52

    I can't find response.send() in the docs, but I assume .send() will fill in and send the response so can only be called once, whereas .write() will just write the response, but you have to send it using response.end()

    This means you can edit the headers using .write() because the response has not been sent yet.

    EDIT :

    response.send() is part of the restify Response API wrapper

提交回复
热议问题