I’m currently using https://www.npmjs.com/package/whatsapp-web.js package and wrote this funciton. I need it to return the client ready to use client eventually. Tried to do it with a promise that resolves when the “ready” event is called. It just didn’t work, it seems like the “ready” event is never called. Any ideas?
await mongoose.connect(process.env.MONGODB_URI!)
const store = new MongoStore({ mongoose: mongoose })
const client = new Client({
authStrategy: new RemoteAuth({
store: store,
backupSyncIntervalMs: 300000,
}),
})
console.log("initializing client")
client.initialize()
return new Promise<wweb.Client>((resolve, reject) => {
client.on("ready", () => {
console.log("client is ready")
resolve(client)
})
})
}```
[1]: https://www.npmjs.com/package/whatsapp-web.js