Here is the code:
function getList() {
return functionList()
.then((list) => functionDetails())
.catch((err) => console.log(err));
}
how to convert it to async/await?
You can wrap the call to the awaited function in a try-catch to handle the error, and then run your .then code in the finally block
async function getList() {
try {
const result = await functionList();
return ((result) => functionDetails()());
} catch(e) {
console.log(e);
}
}
functionDetails in any case, whereas OP calls it only when functionList didn't reject ...finally is executed no matter what you do in the try or the catch block. That's the whole purpose of finally
functionList()?