场景:
下面是反映2个嵌套异步调用的代码,
const create = (request) => {
axios.post(link, body)
.then((response) => {
arr.forEach(obj => {
const file = fs.createWriteStream("./downloads/" + obj.name);
https.get(obj.download_url, response => {
let stream = response.pipe(file);
stream.on("finish", () => {
if (i == count) {
return "Hi...."
}
i++;
});
});
});
})
.catch((error) => {
return error;
});
};
问题:
如何将“ Hi ....”返回给用户。