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
ENDBLOCKBLOCK: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.