Wa-automate-nodejs: getBusinessProfilesProducts returns undefined.

Created on 1 Jul 2020  Â·  7Comments  Â·  Source: open-wa/wa-automate-nodejs

Describe the bug
A clear and concise description of what the bug is.
When using getBusinessProfilesProducts to get my own products, undefined is returned

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create a product in whatsapp business
  2. Obtain wid from getMe() when the session is started
  3. Print in console, getBusinessProfilesProducts results, using my own wid as parameter.

create() code
This is the code you use to create the client. e.g

   const start =  async (client) {
        try {
            const me = await client.getMe();
            const prods = await client.getBusinessProfilesProducts(me.wid)
            console.log(prods)
        } catch (err) {
            console.log(err)
            process.exit(1)
        }
    }
create(this.session,
            {
                executablePath: 'google-chrome',
                qrRefreshS: 30,
                autoRefresh: true,
                useChrome: true,
                throwErrorOnTosBlock: true,
            }
        ).then(client => start(client))
            .catch((err) => {
                console.log("Ha ocurrido un error :: ", err)
                process.exit(1)
            })

Expected behavior
A clear and concise description of what you expected to happen.

All the the products from my account should be shown in console, but undefined is returned

DEBUG INFO
This is the info printed to the console when you start your app. It should look like this

Debug Info {
  WA_VERSION: '2.2025.6',
  PAGE_UA: 'WhatsApp/2.2019.8 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
  WA_AUTOMATE_VERSION: '1.9.91',
  BROWSER_VERSION: 'HeadlessChrome/83.0.4103.116'
}

Screenshots
If applicable, add screenshots to help explain your problem. Use headless: false to get screenshots
On the browser console, using WAPI, the result is different.
image

Host (please complete the following information):

  • OS: Linux Mint

Additional context
If the wid passed to getBusinessProfilesProducts is not a business account, an error is thrown. Shouldn't give an empty array?

bug

Most helpful comment

Done!!!, Working fast and perfect!!!

All 7 comments

@dogcalas I've made some changes to WAPI and tried your code. it is working. I've added some error handling. If it's not a business account it will return false, if there are no products it will return []

@github-actions run


âš¡ Release! âš¡

(async () => {
function exec(cmd) {
  console.log(execSync(cmd).toString());
}

// Config
const gitUserEmail = "github-actions[bot]@users.noreply.github.com";
const gitUserName = "github-actions[bot]";

exec(`echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc`);
exec(`git config --global user.email "${gitUserEmail}"`);
exec(`git config --global user.name "${gitUserName}"`);
exec(`npm i`);
exec(`npm run release-ci`);

//comment on the issue
var result = execSync(`npx auto-changelog -o ./tempchangelog.txt --commit-limit false --template ./compact-keepachangelog.hbs --stdout`).toString();

    await postComment(result);

//create changelog image
exec(`npm run release-image`);
exec(`git commit -a -m 'updated release-image'`);
exec(`git push --force`);
  })();

Changelog

🚀 Release 1.9.92 (2020-07-02)

  • build(deps): bump p-queue from 6.4.0 to 6.5.0 #609
  • build(deps): bump rxjs from 6.5.5 to 6.6.0 #615
  • build(deps-dev): bump typescript from 3.9.5 to 3.9.6 #616
  • build(deps-dev): bump typedoc from 0.17.7 to 0.17.8 #600
  • build(deps-dev): bump release-it from 13.6.3 to 13.6.4 #601
  • build(deps-dev): bump @types/puppeteer from 3.0.0 to 3.0.1 #602
  • onAck fixed #617 #617
  • Doc updates 2fe1f55
  • Release 1.9.92 303b9f2
  • fix: getAllMessagesInChat now works on chats with notifications #610 c1e2726
  • better error handling for business products #612 c875deb

@dogcalas let me know if this is working now thanks

Now is working and solve my problem. Thanks @smashah

Though, it took a lot of time to get just one product.

            console.time();
            const prods = await client.getBusinessProfilesProducts(me.wid)
            console.log(prods)
            console.timeEnd()

In console:
default: 100693.2021484375ms <-- More than one minute.
If I look into web browser console, I can see a lot of requests to resources(images) which belongs to products from other users.

Done!!!, Working fast and perfect!!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

renato-macedo picture renato-macedo  Â·  6Comments

arisros picture arisros  Â·  4Comments

feliperaul picture feliperaul  Â·  5Comments

jazZcarabazZ picture jazZcarabazZ  Â·  5Comments

phantom-limb picture phantom-limb  Â·  5Comments