I'm trying to make a function where I can easily call my MongoDB.
This is the function code/hanlder:
let get = {};
get.getGuildData = (id) => {
const guildData = require('./models/guilds.js')
guildData.findById(id).then(async (data) => {
return guildData.findById(id)
})
};
module.exports = { get }
This is where I am calling the function:
const getGuild = bee.get.getGuildData(msg.guildID)
console.log(getGuild)
It returns undefined, but the console.log on the actual function returns the correct thing:
Let me know if anyone knows a solution to this.
I can not find an answer in this post. How do I return the response from an asynchronous call?