I have a query about handling multiple HTTP requests in my code to ultimately get the desired result.
Here is an outline of my approach:
var customer[];
var url = '/api/project/getCustomer';
getProject(url)
.then(function(data){
var id = data.id
//more code
getCustomer(id)
.then(function(customer) {
//more code
customer.push(customer)
}
}
var getProject = function(url) {
return $http.get(url);
}
var getCustomer = function(id) {
return $http.get('/api/project/getDetail' + id);
}
While my current implementation works, I find that it involves nesting multiple .then
methods in my code. I am curious if there is a more efficient way to achieve this outcome. Thank you for your insights!