我正在做一些承诺,然后将我的结果合并到响应json中。当我console.log时,它会按预期打印出来,但是我不确定如何将其作为响应返回。
我有这样的东西:
router.get('/', function(req, res) {
Promise.all([ fetch(url1); fetch(url2); ]);
}.then(function(responses) {
// Consolidate responses into one data json
console.log(data); // Prints correct object
return response; // This doesn't work
}