Closed tsai0009 closed 5 years ago
My ultimate goal is to have the user actually set an api token for themselves but I am testing the DB first with nickname.
I get the error:
'error: [branch] branch_7 middleware error, Cannot read property 'nickname' of undefined'
When using the code provided in the Amazebot video:
bot.global.text({ after: "call me" }, (b) => { b.users.nickname = b.conditions.captured return b.respond(`OK ${b.user.nickname}`) }) bot.global.text({ contains: "hello" }, (b) => { const nick = b.users.nickname || 'you' return b.respond(`Hey ${nick}`) })
I have an idea of what middleware is, but due to my limited javascript knowledge I don't understand where it is. I am using the default node_modules.
One thing I am getting when I start the bot is:
(node:8660) DeprecationWarning: Mongoose: findOneAndUpdate() and findOneAndDelete() without the useFindAndModify option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#-findandmodify-
findOneAndUpdate()
findOneAndDelete()
useFindAndModify
But it could be unrelated
The problem was actually the syntax being different to that of the video.
It must have changed at some point.
Instead of b.users.nickname change it to b.message.user.nickname
My ultimate goal is to have the user actually set an api token for themselves but I am testing the DB first with nickname.
I get the error:
'error: [branch] branch_7 middleware error, Cannot read property 'nickname' of undefined'
When using the code provided in the Amazebot video:
I have an idea of what middleware is, but due to my limited javascript knowledge I don't understand where it is. I am using the default node_modules.
One thing I am getting when I start the bot is:
(node:8660) DeprecationWarning: Mongoose:
findOneAndUpdate()
andfindOneAndDelete()
without theuseFindAndModify
option set to false are deprecated. See: https://mongoosejs.com/docs/deprecations.html#-findandmodify-But it could be unrelated