小编Jef*_*ick的帖子

AngularJS在get请求中包含API密钥

我正在尝试使用AngularJS从幻想数据API获取信息.我使用$ resource在我的控制器中执行我的get请求,但是我无法弄清楚如何正确地包含API密钥.我是否需要将其作为标题包含在内?谢谢.

nflApp.controller('mainController', ['$scope','$resource','$routeParams', function($scope, $resource, $routeParams) {

$scope.fantasyAPI = $resource("https://api.fantasydata.net/nfl/v2/JSON/DailyFantasyPlayers/2015-DEC-28", { callback: "JSON_CALLBACK" }, { get: { method: "JSONP"}});

console.log($scope.fantasyAPI);

}]);
Run Code Online (Sandbox Code Playgroud)

以下是该站点的http请求信息. http请求信息

javascript angularjs

6
推荐指数
1
解决办法
4118
查看次数

标签 统计

angularjs ×1

javascript ×1