我使用ExpressJS/nodeJS中編寫的服務器從Steam的Web API中抽取了一些JSON形式的文本。這個JSON存儲在一個變量中。ExpressJS將變量傳遞給Angular
我在這裏要做的是基本上把我存儲在變量中的JSON發送給我的Angular,然後將數據顯示在我的頁面上。
當我這樣做,我的控制檯顯示頁面的原始HTML。
有什麼,我失蹤?
我的節點:
app.get('/steam.html', function(req, res){
request.get(steam_api, function(error, steamResponse, steamBody) {
var steamList = JSON.parse(steamBody);
gameList = steamList["applist"]["apps"];
res.json({gl: gameList});
});
});
我的角度:
$http.get('steam.html').success(function(data){
$scope.gameList = data;
console.log(data);
});
我steam.html
<body ng-app="gameSearch" ng-controller="gameSearchController">
<p>{{title}}</p>
<ul ng-repeat="steam in gameList track by $index">
<li>{{steam.name}}</li>
</ul>
</body>
編輯:如果它幫助這裏是我所看到的截圖。正如你將看到的,我得到了一堆的重點,但不是每場比賽的名字。
Express JS passes bullet points
編輯2:另一件事我要補充明確的目標,我使用了一些的NodeJS代碼,我在博文中從codepen如下圖所示(https://codepen.io/johnchristopherjones/post/how-do-i-use-the-steam-api-in-my-web-app):
app.get('/steam/game/:appid/achievements', function(httpRequest, httpResponse) {
// Calculate the Steam API URL we want to use
var url = 'http://api.steampowered.com/ISteamUserStats/GetSchemaForGame/' +
'v2/?key=YOURSTEAMAPIKEYHERE&appid=' +
httpRequest.params.appid;
request.get(url, function(error, steamHttpResponse, steamHttpBody) {
httpResponse.setHeader('Content-Type', 'application/json');
httpResponse.send(steamHttpBody);
});
});
你能提供https://jsfiddle.net/給你的代碼片段嗎? –
這裏你去了:https://jsfiddle.net/ujo8k80e/我應該提到steam_api如我的節點所示是一個鏈接到一個Steam API調用,其中包括我的Steam網絡API密鑰(我不能透過蒸汽網絡API條款 –
更新:在我的HTML中,我將li標籤的內容更改爲'