Search code examples
javascriptpuppeteerwebautomation

Javascript function not called for some reason


I am making a script to automate the procedure of purchasing supreme Items in order to checkout an item before a competitor does. In my script I have already made it so it scans the page for a keyword and then picks that item with a specified size, the only problem I have is that the selectItem() Function is never called at line 451. When you try to run the script it simply does nothing, it was completely functional before I turned the main code into the selectItem() function.

If anyone knows why please tell me, I know some of the code is very messy but it's in very early stages at the moment and will be sorted once it is functional. Thanks in advance.


Solution

  • selectItem() is an async function and should be prefixed with await everytime you call it; for example:

    if(rawTxt1.indexOf(kw) != -1){
          await selectItem(rawTxt1, srcTxt1)