public with sharing class ContinuationClass {
public with sharing class ContinuationClass {
// Action method
@AuraEnabled(continuation=true cacheable=true)
public static Object continuationCall() {
// Create continuation. Argument is timeout in seconds.
Continuation con = new Continuation(120);
// Set callback method
con.continuationMethod='callBackMethod';
// Set state
con.state='Hello, World!';
// Create callout request
HttpRequest req = new HttpRequest();
req.setMethod('GET');
req.setEndpoint(MY_ENDPOINT);
con.addHttpRequest(req);
// Method is returning null from here while calling from lightning instead of returning from the callback response
// Method is returning null from here while calling from lightning instead of returning from the callback response
**return con;** **// Actual return**
}
// Callback method ; This method is executing properly and i m getting the //response as well in my debug
@AuraEnabled(cacheable=true)
public static Object callBackMethod(List<String> labels, Object state) {
// Get the response by using the unique label
HttpResponse response = Continuation.getResponse(labels[0]);
// Set the result variable
String result = response.getBody();
**return result;** // Expected return
}
}
}