-1

i would like to know if it's possible here with $q.all:

            var promise1 =   $http({
                method: 'GET',
                url: "https://cubber.zendesk.com/api/v2/organizations/"+id+"/users.json",
                dataType: 'json',
                headers: {'Content-Type': 'application/json',
                'Authorization': 'Bearer '+token}

            })
            var promise2 = $http({
                method: 'GET',
                url: "https://cubber.zendesk.com/api/v2/users/"+idname+"/tickets/requested.json",
                dataType: 'json',
                headers: {'Content-Type': 'application/json',
                'Authorization': 'Bearer '+token}

            });

            $q.all([promise1, promise2]).then(function(data){
                console.log(data[0], data[1]);
            });

If it's possible to retrieve data from promise 1 and inject into the url of promise 2 and then retrieve full data of both promises in the same array ?

xenurs
  • 459
  • 1
  • 8
  • 19

1 Answers1

2

For example like this

var responses = [];

$http({ ... }).then(function (response) {
    responses.push(response);
    return $http({ ... });
}).then(function (response) { 
    responses.push(response);

    console.log(responses[0], responses[1]);
});

See also this answer, with many different ways to handle it.

Community
  • 1
  • 1
C14L
  • 12,153
  • 4
  • 39
  • 52