As I work on creating an API to retrieve groupChat IDs using the express framework and whatsapp-web-js library, I've encountered an issue. The initial request to the endpoint after starting the server yields a response within 31 seconds, but subsequent responses seem to get stuck in a strange "loop" (although I'm not certain if that's the correct term to describe it).
Here are the steps I've taken so far:
const express = require("express");
const app = express();
app.listen(3000, () => {
console.log("Server running on port 3000");
});
const qrcode = require('qrcode-terminal');
const { Client, LocalAuth } = require('whatsapp-web.js');
const client = new Client({ authStrategy: new LocalAuth() });
app.get("/", (req, res, next) => {
client.on('ready', async () => {
res.json(['test response']);
});
});
I have a feeling that I may be making a mistake somewhere, but I can't pinpoint exactly what it is.