I don't get the response from my second http request after trying to make two http requests in a row with AngularJS.
I have this code:
createBucket: function (bucketKey, policyKey) {
// get token from json file
return $http({
url: tokenUrl
})
.then(function (response) {
token = response.data;
console.log('refreshing access token');
console.log(token);
})
.then(function (response) {
// use token to create new bucket
$http({
method: 'POST',
headers: {
"Authorization": token.token_type + " " + token.access_token
},
url: "https://developer.api.autodesk.com/oss/v2/buckets",
data: {
"bucketKey": bucketKey,
"policyKey": policyKey
}
});
}).then(processResponse);
},
First I do one http request getting a json file. Then using the information in this json file, I do another http request, the result of this request I want to return. In this final code:
// Send the data part of the response
function processResponse(response) {
console.log('response:');
console.log(response);
return response.data;
}
the response here is undefined.. I don't know why...
processResponsefunction.