0
这里是我的代码,在wpt.runtest函数中,我点击了一些url并获得了url的响应,现在我将在我的请求函数中使用这个url,但是我需要等待一段时间,因为需要一段时间才能在请求模块中使用的url上提供数据。如何在nodejs中执行两个函数之间等待
wpt.runTest('http://some url ',function(err, data) {
//console.log("hello -->",err || data);
data_url = data.data.summaryCSV;
console.log(data_url);
console.log('-----------');
console.log(data_url);
console.log('-----------');
request({uri:data_url,method:'GET'}, function (error, response,body) {
console.log('[email protected]@@@@@----');
console.log(response.headers);
console.log('[email protected]@@@@@----');
//console.log(response);
if (error) {
console.log('got an error' + error);
}
//console.log(response);
//console.log(body);
var data = body;
console.log('here is the body' + body);
我想是,应该有一个时间上的差距还是被执行了我的请求函数之前暂停,我怎么能做到这一点
的可能的复制[我该怎么办,如果我想睡觉的JavaScript版本()?](http://stackoverflow.com/questions/951021/what-do-i-做-IF-我想学一,JavaScript的版本的睡眠) –