Skip to content

Instantly share code, notes, and snippets.

@xgeek-net
Last active January 6, 2019 07:22
Show Gist options
  • Save xgeek-net/ab44d9a1b405647f26ed30bd2820e353 to your computer and use it in GitHub Desktop.
Save xgeek-net/ab44d9a1b405647f26ed30bd2820e353 to your computer and use it in GitHub Desktop.
SampleAuraController.js Lightning Component
({
'showAccount' : function(cmp, ev, helper) {
// First Request
var actionOne = cmp.get('c.firstRequest');
actionOne.setParams({ accountId : '001xxxxxxxxxxxx' });
actionOne.setCallback(this, function(res) {
var stateOne = res.getState();
if(stateOne === 'SUCCESS') {
console.log('First From Server-Side: ' + res.getReturnValue());
// Second Request
var actionTwo = cmp.get('c.secondRequest');
actionTwo.setParams({ accountId : '001xxxxxxxxxxxx' });
actionTwo.setCallback(this, function(res) {
var stateTwo = res.getState();
if(stateTwo === 'SUCCESS') {
console.log('Second From Server-Side: ' + res.getReturnValue());
} else if(stateTwo === 'ERROR') {
console.error('ERROR: ' + res.getError());
}
});
$A.enqueueAction(actionTwo);
}
else if(stateOne === 'ERROR') {
console.error('ERROR: ' + res.getError());
}
});
$A.enqueueAction(actionOne);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment