After delving into the concept of promises through this resource, I grasped the fundamental idea behind it.
var parentID;
$http.get('/api/user/name')
.then(function(response) {
parentID = response.data['ID'];
for (var i = 0; i < response.data['event-types'].length; i++) {
return $http.get('/api/security/' + response.data['event-types'][i]['key']);
}
})
.then(function(response) {
// Only one result from the multiple promises in the loop is returned in the response
// Implement logic using parentID;
});
However, my specific scenario demands creating and chaining multiple promises. Despite attempting to chain them as shown above, only one promise generated from the for loop gets executed.
How can I effectively continue chaining all promises while maintaining access to the variable parentID?