node.js - express.js,为什么 res.write 不在 api 引用中

标签 node.js express

形成我的另一个问题can't do multiple res.send in express.js

http://expressjs.com/4x/api.html 中找不到“res.write”

这里是代码示例:

response.write("foo");
response.write("bar");
//...
response.end()

最佳答案

这是因为 res.write 不是 express API 的一部分。这是一个没有express的服务器:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.write('Hi,');
  res.end('Hello World\n');
}).listen(1337, '127.O.O.1');

所以你看到 http 模块已经有 req 和 res 参数,并且向这些对象添加属性表示凑合。

关于node.js - express.js,为什么 res.write 不在 api 引用中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25564398/

相关文章:

node.js - 无法从 Internet 访问 AWS 中使用端口 3000 的 NodeJs 应用程序

javascript - 在 HapiJS Confidence 配置对象中设置过滤对象的默认值

angularjs - RESTful Crud MEAN.js 路由

javascript - Mongoose 没有返回,但 mongo shell 已返回

node.js - 使用 Express 将静态内容提供给子域?

javascript - 使用 Angular.js 中的 post 不起作用

javascript - 如何在Javascript中逐行读取终端命令行的输出

node.js - Ember.js 如何监听服务器发出的事件?

node.js - Node , typescript ERR_MODULE_NOT_FOUND

node.js - 使用 NodeJS 在 Heroku 上验证 Google Sheet API