【发布时间】:2021-01-24 13:29:28
【问题描述】:
我想知道在数据库中发出请求后是否可以在 nodejs 中验证请求。
这是我的代码:
pool.query(`SELECT * FROM * WHERE * = ${pEvent.xxxxx};`, async (e, resultat) => {
if(e){
throw e
}
if(!resultat[0].xxxxx){
console.log(`The item target of ${pEvent.xxxx} called ${pEvent.xxxx} doesn't exist... Do you want to create it ?`)
}else{
const tItemId = resultat[0].xxxx
}
即使在这个“如果”之后,日志也说无法读取未定义的属性 'xxxxxxx'
【问题讨论】:
-
正如日志所说,
resultat[0]是undefined。无法从未定义的权限访问属性。 -
是的,这是我在发布此问题后所看到的。对不起,谢谢你:)
标签: mysql node.js google-cloud-platform google-cloud-functions