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
方法在我的代碼,我想知道如果有一個更好的辦法做這個。非常感謝!