【发布时间】:2015-08-18 11:44:42
【问题描述】:
我正在尝试执行 GET 请求以获取 Steam 市场上单个商品的商品价格信息。
这是我正在使用的确切 angularJS 脚本:
<script>
var app = angular.module('csgo', []);
app.controller('MainCtrl', function($scope, $http) {
$http.jsonp("http://steamcommunity.com/market/priceoverview/?currency=3&appid=730&market_hash_name=StatTrak%E2%84%A2%20P250%20%7C%20Steel%20Disruption%20%28Factory%20New%29").success(function(response) {
$scope.values = response;
console.log(response);
});
});
</script>
当我尝试在浏览器中执行此操作时,我得到:
Uncaught SyntaxError: Unexpected token : ?currency=3&appid=730&market_hash_name=StatTrak™ P250 | Steel Disruption (Factory New):1
在我的 chrome 浏览器控制台中。然后我单击错误消息中的链接 (?currency=3&appid=730&market_hash_name=StatTrak™ P250 | Steel Disruption (Factory New):1)
它把我带到了一行:
{"success":true,"lowest_price":"1,09€ ","volume":"348","median_price":"1,01€ "}
所以我实际上得到了信息,但它给出了一个错误并用红色强调了 JSON 响应。有人知道这个问题吗?
我正在使用 nodejs、express 和 angular。
编辑:
我尝试了不同的网址:https://angularjs.org/greet.php?callback=JSON_CALLBACK&name=Super%20Hero
它适用于这个 URL。所以我不确定为什么我试图请求的原始 URL 不起作用。有什么想法吗?
【问题讨论】:
-
@Huey 感谢您的回复。我尝试删除“/”,但它仍然给了我错误:/
标签: angularjs node.js express get jsonp