繁体   English   中英

如何使用带有 Steam Web API 的 JSON 格式的 javascript-jquery 获取所有 Steam 应用

[英]How to get all steamapps using javascript-jquery in JSON format with Steam web API

我正在尝试使用 Steam API 获取所有 Steam 应用。

JavaScript:

var previewUrl = 
"http://api.steampowered.com/ISteamApps/GetAppList/v0002/?key=mysteamkey&format=json";
  $.ajax({
      type: 'GET',
      url: previewUrl,
      success: function(data) {
        console.log(data);
      },
      error: function(e) {
         console.log(e.message);
      }
  });

但它在控制台上给我这个错误:

CORS 策略已阻止从源“http://localhost:5000”访问“http://api.steampowered.com/ISteamApps/GetAppList/v2/?key=mysteamkey&format=json”上的 XMLHttpRequest:无“访问” Control-Allow-Origin' 标头存在于请求的资源上。

尝试添加crossDomain: true ,它应该修复它。

var previewUrl = 
"http://api.steampowered.com/ISteamApps/GetAppList/v0002/?key=mysteamkey&format=json";
  $.ajax({
      type: 'GET',
      crossDomain:true,
      url: previewUrl,
      success: function(data) {
        console.log(data);
      },
      error: function(e) {
         console.log(e.message);
      }
  });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM