0

I get an error in Chrome saying Error fetching feed: Undefined, 0. Any advice?

My angular code is:

        // Begin SimpleController, with data
        demoApp.controller('SimpleController', function($scope, $http){
            var url = "http://www.grabapper.com/api/v1/iosapps.json";

            $http.jsonp(url).
                success(function(data,status,headers,config){
                    $scope.feed = {
                        title: 'DailyJS',
                        items: data
                    };
                }).
                error (function(data,status,headers,config){
                    console.error('Error fetching feed:', data,status);
                });

        });
        // End SimpleController

all.html:

<li ng-repeat="item in feed.items">

            {{item.name}}

    </li>
sharataka
  • 5,014
  • 20
  • 65
  • 125

1 Answers1

0

Because you are calling cross domain API in your client code. You may checkout this solution.

Here is the code snippet which might shed some light on

$http.defaults.useXDomain = true;
var data =$resource(url);
if(data){
    $scope.feed = {
        title: 'DailyJS',
        items: data
    };
}else{
    console.error('Error fetching feed:', data);
};
Community
  • 1
  • 1
zs2020
  • 53,766
  • 29
  • 154
  • 219