await is only valid in async function

后端 未结 9 1471
青春惊慌失措
青春惊慌失措 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:17

    The current implementation of async / await only supports the await keyword inside of async functions Change your start function signature so you can use await inside start.

     var start = async function(a, b) {
    
     }
    

    For those interested, the proposal for top-level await is currently in Stage 2: https://github.com/tc39/proposal-top-level-await

提交回复
热议问题