CoreUI-AngularJS icon indicating copy to clipboard operation
CoreUI-AngularJS copied to clipboard

$http calls not working

Open olufemioyedepo opened this issue 6 years ago • 1 comments

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(); }

olufemioyedepo avatar Jul 12 '18 12:07 olufemioyedepo

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

bogere avatar Sep 17 '18 15:09 bogere