0
我有一个关于http请求的问题。我需要多个HTTP请求,并得到最终结果如何在我的情况下处理多个http请求?
我的代码
var customer[];
var url = '/api/project/getCustomer';
getProject(url)
.then(function(data){
var id = data.id
//other codes
getCustomer(id)
.then(function(customer) {
//other codes
customer.push(customer)
}
}
var getProject = function(url) {
return $http.get(url);
}
var getCustomer = function(id) {
return $http.get('/api/project/getDetail' + id);
}
我的代码工作,但它需要追加多个.then
方法在我的代码,我想知道如果有一个更好的办法做这个。非常感谢!