我正尝试在异步函数中记录一条语句,如下所示:
async generateCharts (insights) {
const { url } = await this.reportsClient.createReport(insights)
console.log('url from reports', url)
return this.parse(url)
}
虽然没有显示日志语句,但我确定这是因为异步函数。那是对的吗?无论如何要解决这个问题?
最佳答案
Note that errors are swallowed "silently" within an async function – just like inside normal Promises. Unless we add try / catch blocks around await expressions, uncaught exceptions – regardless of whether they were raised in the body of your async function or while its suspended during await – will reject the promise returned by the async function.
关于javascript - Console.log 在异步函数中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41941248/