Here is the code:
function getList() {
return functionList()
.then((list) => functionDetails())
.catch((err) => console.log(err));
}
how to convert it to async/await?
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);
}
}