Postingan

Menampilkan postingan dari Juli, 2023

WhatsApp Web login QR code in an HTML page using whatsapp-web.js

Gambar
To display the WhatsApp Web login QR code in an HTML page using whatsapp-web.js in Windows, you can follow these steps: 1. Install the required dependencies: npm install express qrcode whatsapp-web.js 2. Create a new file named api-browser.js and add the following code: const express = require('express'); const qrcode = require('qrcode'); const { Client } = require('whatsapp-web.js'); const app = express(); const port = 3000; app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html'); }); app.get('/qrcode', async (req, res) => { const client = new Client(); client.on('qr', (qr) => { qrcode.toDataURL(qr, (err, url) => { if (err) { console.error('Error generating QR code:', err); res.sendStatus(500); } else { res.send(` `); } }); }); await client.initialize(); }); app.listen(port, () => { console.log(`Server is running on ht