await 仅在异步函数中有效
2022-08-30 00:07:19
我写了这个代码:lib/helper.js
var myfunction = async function(x,y) {
....
return [variableA, variableB]
}
exports.myfunction = myfunction;
然后我尝试在另一个文件中使用它:
var helper = require('./helper.js');
var start = function(a,b){
....
const result = await helper.myfunction('test','test');
}
exports.start = start;
我收到一个错误:
await is only valid in async function
问题出在哪里?