How to synchronize asynchron request

Following code:

Funktion SendDataToServer(SendURL, AnyData : String) : Boolean;
var
  bOK : Boolean;
begin
  WebHTTPRequest1.Command := httpPOST;
  WebHTTPRequest1.URL := SendURL;
  WebHTTPRequest1.PostData := AnyData;
  WebHTTPRequest1.Execute(
    procedure (AResponse: String; AReq: TJSXMLHttpRequest)
    begin
      ShowMessage('1');
      bOK := (AResponse = 'OK');
    end
  );
  result := bOK;
  ShowMessage('2');
end;

How I expected it shows first the message '2' and then - after the response from server - the message '1'.
How can I do that ShowMessage('2') waits until the anonymous procedure is completely executed? The function should show first the message '1' and then the message '2'.

How can I realize it?

There is at this moment no "wait for" type of code construct.
This will come in pas2js v2.0.
A wait typically blocks the UI and browsers typically want to prevent any UI blocking code.

Dear Mr. Fierens,

Now that the beta has been released, is it now possible to synchronise an asynchron request? If so, how can we achieve this?

Kind regards.

You can use the await functionality offered by the compiler: