18
我们使用request来发出带有node.js的http请求。 我们希望在用户决定时让用户有机会中止请求。这意味着我们必须从请求函数外部触发abort()。也许我们可以从函数内部检查外部变量。 (我们已经尝试在请求开始后将超时设置为零,这不起作用。) 也许我们将变量请求设置为null。你知道更好的方法来做到这一点吗?node.js:如何停止已经启动的http请求
这里是示例代码显示什么样的要求,我们正在谈论:
app.js:
var http = require('http');
var request = require("request");
http.createServer().listen(1337, "127.0.0.1");
request({uri: 'http://stackoverflow.com' }, function (error, response, body) {
console.log('url requested ') ;
if (!error){
console.log(body);
}
else
{
console.log(error);
}
});
有没有很多家伙谁可以快速回答node.js问题的权利。你是其中之一。 –