CoreUI-AngularJS
CoreUI-AngularJS copied to clipboard
$http calls not working
I'm unable to make http calls Here's my code:
testCtrl.$inject = ['$scope', '$http']; function testCtrl($scope, $http) {
$scope.loadPeople = function($http) { return $http.get('https://randomuser.me/api/?results=10') .then(success);
function success(response) {
return response.data;
console.log(response.data);
}
// $http({
// method : "GET",
// url : "https://randomuser.me/api/?results=10"
// }).then(function mySuccess(response) {
// $scope.myWelcome = response.data;
// }, function myError(response) {
// $scope.myWelcome = response.statusText;
// });
} $scope.loadPeople(); }
But my $http calls are working
It seems you are redefining the $http service yet it is already defined.
$scope.loadPeople = function($http) { return $http.get('https://randomuser.me/api/?results=10') .then(success);
try testing this code snippet and see the results
app.controller('myCtrl', function($scope, $http) {
$http.get("http://localhost:3010/api/balah")
.then(function(response) {
$scope.myWelcome = response.data;
});
});
Test that and see but such questions should be posted on stackoverflow. Only bug related issues should be posted here