Reputation: 165
I have this working code in node project
export function startWhatsapp(){
const qrcode = require('qrcode-terminal');
const { Client } = require('whatsapp-web.js');
const client = new Client();
client.on('qr', qr => {
qrcode.generate(qr, {small: true});
});
client.on('ready', () => {
console.log('Client is ready!');
});
client.initialize();
}
I need to use it in my angular app what is the best practice to do it ?
Upvotes: 0
Views: 223
Reputation: 3036
You can use node
web server, setup with express
. It is quite easy to setup, then expose a simple API from the express server and use HttpClient
from Angular to call the API.
If you want it more real time, based on the event, you can even use socket.io
with node express server.
https://medium.com/@raj_36650/integrate-socket-io-with-node-js-express-2292ca13d891
You can use socket.io even on client side, so the it allow real time communication.
Upvotes: 1