首页 > 代码库 > $http questions

$http questions

 //////1

$http.get("/api/task/165/").then(
function(a){
console.log(a);
},
function(b){
console.log(b);
}
)
.then(function(e){
console.log("e");
})
.then(function(){
console.log("err");
});

/////2

$http.get("/api/task/1651/").then(
function(a){
console.log(a);
}
)
.catch(function(err){
console.log(err);
})
.then(function(e){
return $http.get("/api/task/165/");
})
.then(function(res){
console.log(res);
})

////3

$http.get(‘https://api.github.com/users/peterbe/gists‘)
.success(function(data) {
  $scope.gists = data;
})
.error(function(data, status) {
  console.error(‘Repos error‘, status, data);
})
.finally(function() {
  console.log("finally finished repos");
});

 

$http.get(‘https://api.github.com/users/peterbe/gists‘)
.then(function(response) {
  $scope.gists = response.data;
})
.catch(function(response) {
  console.error(‘Gists error‘, response.status, response.data);
})
.finally(function() {
  console.log("finally finished gists");
});

 

$http questions