我正在使用 node 的express.js,并测试某些路由.我要在http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/岁的时候做这门课
我通过ajax给http://localhost:3000/wines
打电话(内容无关紧要).但我想测试延迟.我能在2秒钟后做出快速回复吗?(我想模拟ajax加载程序,我在localhost上运行,所以我的延迟几乎为零)
我正在使用 node 的express.js,并测试某些路由.我要在http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/岁的时候做这门课
我通过ajax给http://localhost:3000/wines
打电话(内容无关紧要).但我想测试延迟.我能在2秒钟后做出快速回复吗?(我想模拟ajax加载程序,我在localhost上运行,所以我的延迟几乎为零)
只需在setTimeout内拨打res.send
:
setTimeout((() => {
res.send(items)
}), 2000)