When attempting to retrieve the attribute of a response object, it is returning as "undefined".
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope, $http) {
$scope.addNewChoice = function () {
console.log('aaaa');
$http.get("http://api.nexmo.com/verify/json?api_key=569b1af&api_secret=d0de241&number=918650298011&brand=MyApp").success(function(response) {$scope.res = response.data;});
console.log(res.request_id);
console.log(res.status);
console.log(res.error_text);
};
});
Result in web console:
aaaa
angular.min.js:102 ReferenceError: res is not defined
Any suggestions on what might be going wrong in my code?