我尝试将同步函数传递给异步函数,这会引发错误
(节点:20853)UnhandledPromiseRejectionWarning:TypeError:res不是函数
``
const puppeteer = require('puppeteer')
const csv = require('csv-array')
function res(){
csv.parseCSV('keywords.csv', function (data) {
retValue = JSON.stringify(data)
// console.log(retValue)
return retValue
},false)
}
(async () => {
// somehow I need the array inside this, so I can loop
var x=await res();
for(leti=0;i<10;i++){
await console.log(x(i));
)
})()