Skip to main content
added 10 characters in body
Source Link
Sebastian Kessel
  • 13.2k
  • 12
  • 38
  • 61

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
    }
}

}

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

  **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
}

}

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

      **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
    }
}
Source Link

continuation method return null from the continuation method it self instead of call back method return

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

  **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
}

}