0
I’m using Venom.js to send messages by Whatsapp, it works perfectly, as long as the client sends the first interaction, ie when I try to send some basic text, at first it sends, but the second time I run the code it, Promise error appears in Puppeteer, I already searched the internet something that talks about but unsuccessfully; I tried to use Sulla, but the problem is the same, Follow the code and just below the error, I thank the staff of the forum, for giving valuable time to answer us;
const venom = require('venom-bot');
venom.create().then((client) => start(client));
async function start(client) {
// Send basic text
await client
.sendText('[email protected]', 'Olá Sou um Robô!')
.then((result) => {
console.log('Result: ', result.status);
})
.catch((erro) => {
console.error('Error no Processo: ', erro.status); //return object error
});
}
I tried with async/await or without, but it only works once, maybe it’s a detail, but I need it to work constantly, because I will put data from a setInterval and every time another api receives a response will call Venomjs so it can send to Whatsapp;
(node:5420) UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: WAPI is not defined
at __puppeteer_evaluation_script__:3:45
at ExecutionContext._evaluateInternal (C:\wamp64\www\apiplug\desktop_dev\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:221:19)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async ExecutionContext.evaluate (C:\wamp64\www\apiplug\desktop_dev\node_modules\puppeteer\lib\cjs\puppeteer\common\ExecutionContext.js:110:16)
(node:5420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use
the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This doesn’t really answer the question. If you have a different question, you can ask it by clicking on Ask question. You can also add a bonus to draw more attention to this question when you have reputation points sufficient.
– Marcos Alexandre