// AngularJS Promise Chaining
function getData() {
return $http.get('api/data')
.then(function(response) {
return response.data;
})
.then(function(data) {
return $http.get('api/details/' + data.id);
})
.then(function(detailsResponse) {
return detailsResponse.data;
})
.catch(function(error) {
console.error('Error:', error);
});
}
// Vue.js Promise Chaining
methods: {
getData() {
return this.$http.get('api/data')
.then(response => response.data)
.then(data => this.$http.get('api/details/' + data.id))
.then(detailsResponse => detailsResponse.data)
.catch(error => console.error('Error:', error));
}
}