Create a function with form that can be used in Await

I'll be honest, asking here to try and save some time.

I want to create a method that can be called within Await (so has to have a TJSPromise result). I tried wrapping the code in a TJSPromise.new but get a 'can't call await in a non asymc method'. any pointers?

this code is in a function marked [async].

result := TJSPromise.new(

    procedure(ASuccess, AFailed: TJSPromiseResolver)
    begin
      AForm := TInputQueryForm.Create(Self);
      try
        AForm.Popup := True;
        AForm.PopupOpacity := 1;
        await(TWebForm, AForm.Load());
        AForm.Prompt := APrompt;
        AForm.EditType := AEditType;
        AForm.InputValue := AValue;

        lRetval := await(TModalResult, AForm.Execute);

        ASuccess := lRetval = mrOK;
        if ASuccess then
          AValue := AForm.InputValue;

      finally
        AForm.Free;
        AForm := nil;
      end;
    end

    );

Hi Russell,

I'm not doing the same thing but I use:

        tblImages.FieldByName('Img').AsString:=Await(String,TJSPromise.new(
          procedure(ASuccess,AFailed:TJSPromiseResolver)
          begin
            ASuccess(Img.Base64Image);
          end
        ));

Regards,

Ken