'Looping through MongoDB data returns 'undefined'
I'm trying to make it so that if you use a command, it sends all the content of my MongoDB schema. For some reason, it won't work and is printing this error: "TypeError: Cannot read properties of null (reading 'eventName')"
Here's the code, thanks.
else if (command === 'events') {
const allEvents = EventDatabase.find()
let desc = '';
for (const i in allEvents) {
desc += `${allEvents[i].eventName}). ${allEvents[i].eventInfo}\n`
}
await message.channel.send(desc)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
