Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WPP.chat.getMessageById and WPP.chat.getMessages always return undefined #957

Closed
Gethin0321 opened this issue Mar 6, 2023 · 1 comment
Closed
Labels
bug Something isn't working needs triage

Comments

@Gethin0321
Copy link

Description

[Description of the bug, When Issue Happens]

Environment

  • WhatsApp version: 2.2308.7
  • WA-JS version(s): 2.20.2
  • Browser: Chromium 982053
  • OS: ubuntu 16.04
  • MultiDevice (BETA): yes

1,WPP.chat.getMessages

let chat_id = '9195xxxxxxx@c.us';
   const result = await client.pupPage.evaluate(
                        (chat_id) => WPP.chat.getMessages(chat_id,{
                            count:20,
                        }),
                        chat_id,
                    );
console.log(result);

got undefined

2,WPP.chat.getMessageById

 let message_id = 'false_91xxxxxxx@c.us_3EB052F0692148177865';
  const result = await client.pupPage.evaluate(
                        (message_id) => WPP.chat.getMessageById(message_id),
                        message_id,
                    );

console.log(result);

got undefined

@Gethin0321 Gethin0321 added bug Something isn't working needs triage labels Mar 6, 2023
@icleitoncosta
Copy link
Contributor

icleitoncosta commented Mar 24, 2023

This is possibly an error in your code, it could be in the Puppeteer configuration.

You can call the functions directly through the browser console and test them.
In a simple way: open the project through VSCode -> Run -> Start Debugging, it will open an instance of chrome, you can directly call the function in the console.

Something like:

await WPP.chat.getMessageById('messageId');

You can see that it continues to function normally.

Well, did you do that and did it work? We have to check your code, but there is a problem in Puppeteer, an issue already known and discussed by them, which brings undefined returns, in the WppConnect LIB it is treated like this: JSON.parse(JSON.stringify(result));

It's something you can try, here's a reference:
https://github.com/wppconnect-team/wppconnect/blob/master/src/api/layers/sender.layer.ts
(Line 125 ex )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants