我想获取多个异步url,对其进行解析并为继续代码返回值。
const Promise = require("bluebird");
const rp = require('request-promise');
var request1 = rp('https://www.wp.pl');
var request2 = rp('https://www.google.pl');
var request3 = rp('https://www.dell.com/support/home/pl/pl/pldhs1/product-support/servicetag/41H3D5J/diagnose');
//var request4 = ......
var output = Promise.all([request1, request2, request3])
.spread(function (responseOfReq1, responseOfReq2, responseOfReq3) {
console.re.log(responseOfReq1.split("\n")[0]);
console.re.log(responseOfReq2.split("\n")[0]);
console.re.log(responseOfReq3.split("\n")[2]);
//parse result and return data
return 'aaaaa'; //return data;
})
.catch(function (err) {
if(err!='')
console.re.error(err);
});
console.re.info('done get urls');
console.re.debug(output);
控制台返回responseOfReq1
,responseOfReq2
,responseOfReq3
,但执行代码已锁定在Promise上,而console.re.info('done get urls');
却没有。
哪里有问题?