【发布时间】:2019-12-29 10:19:37
【问题描述】:
try/catch 对 client.connect() 不起作用:
const { Pool, Client } = require('pg')
try {
const client = new Client(config)
client.connect()
} catch (er) {
console.log('error')
}
错误:
UnhandledPromiseRejectionWarning: error: password authentication failed for user '...'
如何更改异步 connect() 以同步 try/catch?
【问题讨论】:
-
在异步函数中等待它,或者使用 .then 和 .catch 代替
标签: node.js postgresql error-handling node-postgres