码迷,mamicode.com
首页 > 其他好文 > 详细

express respond.send 和 end的区别

时间:2017-12-29 15:01:08      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:data   call   spec   with   htm   process   body   blog   actual   

做个记录

res.send() will send the HTTP response. Its syntax is,

res.send([body])

The body parameter can be a Buffer object, a String, an object, or an Array. For example:

res.send(new Buffer(‘whoop‘));
res.send({ some: ‘json‘ });
res.send(‘<p>some html</p>‘);
res.status(404).send(‘Sorry, we cannot find that!‘);
res.status(500).send({ error: ‘something blew up‘ });

  

See this for more info.

res.end() will end the response process. This method actually comes from Node core, specifically the response.end() method of http.ServerResponse. It is used to quickly end the response without any data. For example:

res.end();
res.status(404).end();

Read this for more info.

express respond.send 和 end的区别

标签:data   call   spec   with   htm   process   body   blog   actual   

原文地址:https://www.cnblogs.com/yehuabin/p/8143362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!