call TWebHTTPRequest self create in pascal proc from ASM failed

Hi,
I have a pascal proc like this

procedure TCompanyDetailForm.doLoadActions(pXHRUrl : String;pCon_Ref : Integer);
var
aURL : String;
axhresult : TJSXMLHttpRequest;
aData,
aresponse : JSValue;
aXHR_Actions : THTTPRequest;
begin
// --- Init
aXHR_Actions := THTTPRequest.Create(Self);
try
finally
end;
end;

it calls from pascal function first. And during API I call this a second time but from an ASM block
like this

asm
function reLoadActions()
{
// UCompanydetail and var allready defined

  UCompanydetail.doLoadActions(aURL,gcompany_id);
}

reLoadActions();
end;

Now I have this error
Uncaught TypeError TypeError: Cannot use 'in' operator to search for '4' in undefined

Could you help me.
Thanks

I find doing it this way is more reliable:

pas.MyFrm.MyForm.doLoadActions(aURL,gcompany_id);

Not sure how you get UCompanydetail but I could not see an issue with:

procedure TForm1.doLoadActions(pXHRUrl : String;pCon_Ref : Integer);
var
  aURL : String;
  axhresult : TJSXMLHttpRequest;
  aData, aresponse : JSValue;
  aXHR_Actions : THTTPRequest;
begin
  // --- Init
  aXHR_Actions := THTTPRequest.Create(Self);
  try
  finally
  end;
end;

procedure TForm1.WebButton1Click(Sender: TObject);
var
  aURL: string;
  gcompany_id: integer;
  frm: TForm1;
begin
  frm := Self;
  aURL := 'https://www.tmssoftware.com';
  gCompany_ID := 1;
   asm
   function reLoadActions()
   {
   // UCompanydetail and var allready defined
     frm.doLoadActions(aURL,gcompany_id);
   }
   reLoadActions();
  end;
end;

I have already defined this call with a global JS var
var UCompanydetail = pas.UCompanyDetailForm.TCompanyDetailForm;

It's not the calling who failed but when call from asm just at the creation of
aXHR_Actions := THTTPRequest.Create(Self);
there's this cascading error
Uncaught TypeError TypeError: Cannot use 'in' operator to search for '4' in undefined
at ValidateRename (c:\Users\Gilles.vscode\extensions\tmssoftware.tmswebcore-2.1.6240\resources\coresource\RTL\classes.pas:5566:19)
at InsertComponent (c:\Users\Gilles.vscode\extensions\tmssoftware.tmswebcore-2.1.6240\resources\coresource\RTL\classes.pas:5795:3)
at Create$1 (c:\Users\Gilles.vscode\extensions\tmssoftware.tmswebcore-2.1.6240\resources\coresource\RTL\classes.pas:5637:34)
at Create$1 (c:\Users\Gilles.vscode\extensions\tmssoftware.tmswebcore-2.1.6240\resources\coresource\WEBLib.REST.pas:258:3)
at c.$create (c:\Users\Gilles.vscode\extensions\tmssoftware.tmswebcore-2.1.6240\resources\coresource\RTL\rtl.js:332:1)

Thanks

Thanks Bruno there's the good solution.