Home > other >  Nodejs asynchronous problem
Nodejs asynchronous problem

Time:09-20

 async function test () {
Let the result=await new Promise ((resolve, reject)=& gt; {
Request (' https://ncov.dxy.cn/ncovh5/view/pneumonia '(err, data)=& gt; {
If (err) {
Reject (err)
} else {
Resolve (data)
}
})
})

Fs. WriteFile ('./result. TXT ', the result, (err)=& gt; {
If (err) {
The console. The log (err)
} else {
The console. The log (' success ')
}
})
}
test();

I want to know why my this request for data result cannot be written into the file
  • Related