await is only valid in async function

后端 未结 9 1587
青春惊慌失措
青春惊慌失措 2020-11-22 06:53

I wrote this code in lib/helper.js

var myfunction = async function(x,y) {
   ....
   return [variableA, variableB]
}
exports.myfunction = myfunct         


        
9条回答
  •  失恋的感觉
    2020-11-22 07:24

    "await is only valid in async function"

    But why? 'await' explicitly turns an async call into a synchronous call, and therefore the caller cannot be async (or asyncable) - at least, not because of the call being made at 'await'.

提交回复
热议问题