In my Lightning Component, I'm doing a very simple call to server side action which is executed when you click on a button, here's an example:
getCustomObjects: function(component) {
var action = component.get('c.getCustomObjects');
action.setCallback(this, function(response){
var state = response.getState();
if (state === 'SUCCESS') {
console.log(response.getReturnValue());
component.set('v.CustomObjects', response.getReturnValue());
}
});
$A.enqueueAction(action);
}
I then have an APEX controller, that does a simple query to return all Custom Objects in our records. Like below:
public with sharing class CustomObjectController {
@AuraEnabled
public static List getCustomObjects() {
List<CustomObject__c> objects = [SELECT Id, object_name__c FROM CustomObject__c];
return objects;
}
}
When I press the button to execute the getCustomObjects method, response.getReturnValue() returns undefined and it seems it gets stuck in an infinite loop and then crashes with the error below:
My example is based from this article and I'm not sure what I'm doing wrong or what checks I have to do to see why this is happening. Performing the query in the Developer Console returns all the records that I need.