want to use the whats app web.js in alpine js

47 views Asked by At

I'm trying to use what's app web.js in Alpine js and I'm writing all the js in a separate file unable to import the package

`   document.addEventListener('alpine:init', () => {
    Alpine.data('generateQR', () => ({
        init() {
            console.log('Alpine initialized');
            this.qr();
        },

        async qr() {

            const { Client } = require('whatsapp-web.js');

            const client = new Client();

            client.on('qr', (qr) => {
                // Generate and scan this code with your phone
                console.log('QR RECEIVED', qr);
            });

            client.on('ready', () => {
                console.log('Client is ready!');
            });

            client.on('message', msg => {
                if (msg.body == '!ping') {
                    msg.reply('pong');
                }
            });

            client.initialize();
        }
    }));
});    `

this is what I have done

I wanna know how to use the external packages in alpine js and an example of whats app web.js tried to read the docs but was unable to find my answer so if anyone able to solve my problem it's a big help

0

There are 0 answers