Evaluation failed: ReferenceError: $ is not defined

I’m trying to use ExecuteJS Block (Puppeteer) for running ajax xhr request, but unfortunately that OB2 always send the error:

Evaluation failed: ReferenceError: $ is not defined at puppeteer_evaluation_script:1:1

This is my ajax query setting script:

  var settings = {
  "url": "https://www.URL.com/api/auth/login",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "accept": " */*",
    "accept-encoding": " gzip, deflate, br",
    "accept-language": " en-GB,en-US;q=0.9,en;q=0.8",
    "content-type": " application/json",
    "origin": " https://www.URL.com",
    "referer": " https://www.URL.com/"
  },
  "data": "{\"login\":\"<INPUT.USER>\",\"password\":\"<INPUT.PASS>\"}",
  "async": false,
  "success": function (data){
  },
  "error": function (xhr) {
        alert('error');
    }
};

This is my xhr runner:

$.ajax(settings).done(function (login_status) { });

Here is my Loli:

BLOCK:PuppeteerExecuteJs
LABEL:/* Build data */
expression = “var settings = { "url": "URL.com - MediaOptions”, "method": "POST", "timeout": 0, "headers": { "accept": " /", "accept-encoding": " gzip, deflate, br", "accept-language": " en-GB,en-US;q=0.9,en;q=0.8", "content-type": " application/json", "origin": " https://www.URL.com", "referer": " https://www.URL.com" }, "data": "{\"login\":\"<INPUT.USER>\",\"password\":\"<INPUT.PASS>\",\"loginForCheckout\":true,\"isKeepSignedIn\":false}", "async": false, "success": function (data){ }, "error": function (xhr) { alert(‘error’); } };"
=> VAR @puppeteerExecuteJsBuilddata
ENDBLOCK

BLOCK:PuppeteerExecuteJs
LABEL:/* Function for calling request */
expression = “$.ajax(settings).done(function (login_status) { \t});”
=> VAR @puppeteerExecuteJscallingrequest
ENDBLOCK

Does anybody here can help me on this please?

It’s really hard to fix because somehow few times It worked then this issue happen again.

@Ruri can you help me to fix this issue please? Thanks alot

seems this block is giving error with ajax’s $ variable. I am currently working around it by using xhr request as an alternative to ajax request. It’s work well but I still want to use ajax for many other case.

I honestly don’t know, maybe seek help on some puppeteer related forum since I’m just calling puppeteer functions here, the blocks are just wrappers to call methods of puppeteer, I don’t do weird custom implementations.

Thanks @Ruri

I think maybe I have to use JS xhr request instead.

Do you have any plan to intergrate Geeko Firefox lib into OB2?

I have no plans of doing that, sorry