有人可以解釋一下嗎?
在我的信使機器人中,我有以下代碼:
entry.messaging.forEach(async function (webhookEvent) {
// Discard uninteresting events
if ("read" in webhookEvent) {
console.log("Got a read event");
return;
} else if ("delivery" in webhookEvent) {
console.log("Got a delivery event");
return;
} else if (webhookEvent.message && webhookEvent.message.is_echo) {
console.log(
"Got an echo of our send, mid = " webhookEvent.message.mid
);
return;
}
我得到的錯誤:
entry.messaging.forEach( /*#__PURE__*/function () {
TypeError: Cannot read properties of undefined (reading 'forEach')
uj5u.com熱心網友回復:
您應該首先檢查 entry.messaging 的存在,然后為其創建一個 forEach 回圈。如下所示:
entry.messaging && entry.messaging.forEach(...)
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/512445.html
上一篇:如果呼叫函式的腳本不是主應用程式.js檔案,為什么res.sendFile不能訪問__dirname "/../public"
