I have this function that sends an HTTP web request but after I get the response, I need to return a value from the lambda function and not the SendRequest function itself.
void OpenAiSdk::DispatchRequest()
{
// I need to get the return value from the lambda function
FChatCompletionCreateResponse response = SendRequest(outputString);
}
void OpenAiSdk::SendRequest(FString outputString)
{
FHttpModule* http = &FHttpModule::Get();
TSharedRef<IHttpRequest> r = http->CreateRequest();
r->OnProcessRequestComplete().BindLambda([&](FHttpRequestPtr req, FHttpResponsePtr res, bool bWasSuccessful)
{
FChatCompletionCreateResponse* chatCompletionResponse = new
FChatCompletionCreateResponse;
if (bWasSuccessful)
{
...
return chatCompletionResponse;
}
}