Last active
January 6, 2019 07:22
-
-
Save xgeek-net/ab44d9a1b405647f26ed30bd2820e353 to your computer and use it in GitHub Desktop.
SampleAuraController.js Lightning Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
'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