As I'm new to Promises/async/await and modern JavaScript, I'm a bit confused about how could it be possible to return value of "then" function for parent function:
async function f1() {
return 1;
}
function f2() {
f1().then((f1_output) => {
console.log(f1_output);//write 1 on console
return f1_output;
})
}
let f2_output = f2();//I expect to get 1 (f1_output)
console.log(f2_output);//undefined
It is a part of web scraping project in NodeJS, f1 is actually fetch some data from web, f2 apply some modification on result. I don't have access to f1 and I can't change it! In other hand, I can change/build f2 whatever I want. Btw, sorry for my bad English! :)