我正在尝试使用箭头函数定义异步函数。这段代码已经抛出了一个错误,但我仍然想知道主要错误是什么。
async responseName = name => ('hello'+ name);
responseName('joshua').then(response => console.log(response));
最佳答案
您有语法错误。您不能将标识符定义为异步:
const responseName = async (name) => `hello ${name}`;
关于javascript - 尝试定义异步函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54131089/