What is the difference between res.send and res.write in express?

前端 未结 4 498
挽巷
挽巷 2020-12-04 19:27

I am a beginner to express.js and I am trying to understand the difference between res.send and res.write ?

4条回答
  •  余生分开走
    2020-12-04 19:39

    Suppose you have two line that needs to be shown up and you use res.send as

    res.send("shows only First Line")
    res.send("won't show second Line")
    

    Then only first line will show up, whereas using res.write you have flexibility to write multiple line such as

    res.write("Shows first line")
    res.write("Shows second line")
    res.send()
    

提交回复
热议问题