Im trying to create a get function that will have a dynamic URL for variables needed from an api. I am assigning the $scope variable to the returned data however I cannot access it. I console log the variable and it returns undefined. Below is my code.
app.controller('Controller', function ($scope, $http) {
var getRequest = function (url) {
$http({
method: 'GET',
dataType: "json",
url: url
}).then(function (response) {
console.log(response);
return response;
}),
function error(err) {
console.log("This ain't working..." + err);
}
}
$scope.firstURL = getRequest('https://url1');
$scope.secondURL = getRequest('https://url2');