I am working on a basic angular $http.get request that returns a json object. What I need is to extract the id from the response and use it for another $http.get call. The solution I have in place involves nesting another $http.get within the first one, but I feel there must be a more efficient way to achieve this. How can I effectively store the id from the jsonResponse into a variable? I am encountering some challenges with variable scope as I attempt to assign the value to a variable.
$http.get('/api/v1/foo/userinfo?thunk='+thunk+'&bar='+bar).success(function(data) {
$scope.id = data.id
}).then(function(data){
$scope.id = data.data.id
});