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
例如:
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
形成我的另一个问题不能在 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)