SCENARIO:
Below is the code that reflect 2 nested asynchronous call,
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;
});
};
QUESTION:
How can I return "Hi...." back to the user.