Skip to content

Instantly share code, notes, and snippets.

@olopsman
Created June 22, 2020 11:08
Show Gist options
  • Select an option

  • Save olopsman/1e61a0b0158be7770e700168997ca718 to your computer and use it in GitHub Desktop.

Select an option

Save olopsman/1e61a0b0158be7770e700168997ca718 to your computer and use it in GitHub Desktop.
apexPromise : function(component, methodName, params) {
return new Promise($A.getCallback(function(resolve, reject) {
var action = component.get(methodName);
action.setParams(params);
action.setCallback(self, function(res) {
var state = res.getState();
if(state === 'SUCCESS') {
resolve(res.getReturnValue());
} else if(state === 'ERROR') {
reject(action.getError())
}
});
$A.enqueueAction(action);
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment