Below is my code snippet:
var exchange = angular.module('app', []);
exchange.controller('ExchangeController', ExchangeController);
function ExchangeController($scope, $http) {
$scope.items = [];
$http
.get(window.location.origin + "/api/get-item/", {
transformRequest: angular.identity,
headers: {'Content-Type': undefined, 'Process-Data': false}
})
.then(function(response){
$scope.items = response.data.items;
console.log($scope.items);
});
console.log($scope.items);
}
The first console.log statement is working fine, but the second one is showing 'undefined'. Any insights on why?