$http GET method Displays Blank Page

302 Views Asked by At

I tried to parse json using below code but it is displaying a blank page.

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
  $http.get("http:krispypapad.herokuapp.com/fetch_article").success(function (response) {   
      $scope.myWelcome = data.response;

    });  
});
2

There are 2 best solutions below

1
On

I think there is typo with the URL you are using:

http:krispypapad.herokuapp.com instead http://krispypapad.herokuapp.com you are missing a couple of //

This is how your code will look like:

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope, $http) {
  $http.get("http://krispypapad.herokuapp.com/fetch_article").success(function (response) {   
      $scope.myWelcome = response; //<-- no .data is required

    });  
});
1
On

You have a typo in the URL, it should be like this:

http://krispypapad.herokuapp.com/whatever

Also you should use response.data not data.response