Recommended Usage of the Callback Functions
The following example describes how you should not execute $db.get API immediately after $sfm_records.get API as JavaScript is not a synchronous language.
$event.get(function(response) {
$sfm_records.get(function(response) {
});
//Below API execution is wrong.
$db.get(function(response) {
});
});
The following example describes how to execute the API when the callback function gets a response.
$event.get(function(response) {
$sfm_records.get(function(response) {
$db.get(function(response) {
});
});
});