Node.js 异步/等待函数返回未定义
是的,我以前搜索过,是的,这是关于等待/异步函数的另一个问题 我很抱歉,如果我的问题是重复的,但我没有找到解决方案Node.js 异步/等待函数返回未定义,node.js,async-await,undefined,Node.js,Async Await,Undefined,是的,我以前搜索过,是的,这是关于等待/异步函数的另一个问题 我很抱歉,如果我的问题是重复的,但我没有找到解决方案 //获取投票结果 异步函数foo(param){ 常量REACT_OPTS=['1️⃣', '2.️⃣', '3.️⃣', '4.️⃣', '5.️⃣', '6.️⃣', '7.️⃣', '8.️⃣', '9️⃣', ' 您正在从foo函数和栏中导出{opts,results} 函数必须使用与{opts,results}相同的名称来分解结构,而不是{opts,res} 尝试使用下栏
//获取投票结果
异步函数foo(param){
常量REACT_OPTS=['1️⃣', '2.️⃣', '3.️⃣', '4.️⃣', '5.️⃣', '6.️⃣', '7.️⃣', '8.️⃣', '9️⃣', ' 您正在从foo函数和栏中导出{opts,results}
函数必须使用与{opts,results}
相同的名称来分解结构,而不是{opts,res}
尝试使用下栏功能再次运行代码:
async function bar() {
// Get poll opts/results and publish channel
const { opts, results } = await foo(param);
console.log('bar', opts, results);
}
但是,如果您想使用res,请为结果提供别名,如const{opts,results:res}=wait foo(param);
您正在从foo函数导出{opts,results}
函数必须使用与{opts,results}
相同的名称来分解结构,而不是{opts,res}
尝试使用下栏功能再次运行代码:
async function bar() {
// Get poll opts/results and publish channel
const { opts, results } = await foo(param);
console.log('bar', opts, results);
}
但是如果你想使用res,那么为结果提供别名,比如const{opts,results:res}=wait foo(param);
谢谢!!!我觉得自己太笨了…现在我更明白如何提取mod了。谢谢!!!我觉得自己太笨了…现在我更明白如何提取mod了。