Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 异步/等待函数返回未定义_Node.js_Async Await_Undefined - Fatal编程技术网

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了。