AngularJS Flickr API 'Uncaught SyntaxError: Unexpected token <'

AngularJS Flickr API 'Uncaught SyntaxError: Unexpected token <'

我正在尝试使用 AngularJS 从 Flickr 获取 public 张照片并收到此控制台错误:

Uncaught SyntaxError: Unexpected token <

这是我的代码:

  var app = angular.module('plunker', ['ng', 'ngResource']);
  app.controller('MainCtrl', function($scope, $http) {
      $http.jsonp('https://api.flickr.com/services/feeds/photos_public.gne?&callback=JSON_CALLBACK').then(function (data) {
        $scope.data = data;
        console.log(data);
      });
  });

这是我的 Plunker:

http://plnkr.co/edit/vB9BJDh6B8DtSFlod1F2?p=preview

如何防止此错误发生?

您正在使用 API 的 flickr url returns XML.

在请求url中添加format=json。另外,将 callback=JSON_CALLBACK 替换为 jsoncallback=JSON_CALLBACK.

综上所述,这样查询:

$http.jsonp('https://api.flickr.com/services/feeds/photos_public.gne?format=json&jsoncallback=JSON_CALLBACK').then(function (data) {
    $scope.data = data;
    console.log(data);
});

updated plunker