小编emj*_*365的帖子

不能在express.js中做多个res.send

3年前,我可以在express.js中做多个res.send.
甚至写一个setTimeout来显示实时输出.

response.send('<script class="jsbin" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>');
response.send('<html><body><input id="text_box" /><button>submit</button></body></html>');
var initJs = function() {
  $('.button').click(function() {
    $.post('/input', { input: $('#text_box').val() }, function() { alert('has send');});
  });
}
response.send('<script>' + initJs + '</script>');
Run Code Online (Sandbox Code Playgroud)

现在它将抛出:

Error: Can't set headers after they are sent
Run Code Online (Sandbox Code Playgroud)

我知道nodejs和express已更新.为什么现在不能这样做?还有其他想法吗?


找到解决方案,但"res.write"不在api参考http://expressjs.com/4x/api.html ...

:S

node.js express

27
推荐指数
2
解决办法
3万
查看次数

typeorm - 如何向“多对多”表添加额外字段?

例如:

3桌

user
user_business_lines_business_line
business_line
Run Code Online (Sandbox Code Playgroud)

那些由typeorm声明创建的User

@ManyToMany(type => BusinessLine)
@JoinTable()
businessLines: BusinessLine[]
Run Code Online (Sandbox Code Playgroud)

然后,如何添加列字段,如

@CreateDateColumn({ type: 'timestamp' })
createdAt: Date

@UpdateDateColumn({ type: 'timestamp' })
updatedAt: Date
Run Code Online (Sandbox Code Playgroud)

user_business_lines_business_line

typeorm

7
推荐指数
2
解决办法
6934
查看次数

express.js,为什么 res.write 不在 api 参考中

形成我的另一个问题不能在 express.js 中执行多个 res.send

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

这是代码示例:

response.write("foo");
response.write("bar");
//...
response.end()
Run Code Online (Sandbox Code Playgroud)

node.js express

2
推荐指数
1
解决办法
1639
查看次数

标签 统计

express ×2

node.js ×2

typeorm ×1