【问题标题】:Steam WEB API. Is it possible to get data on localhost in Vue.js?蒸汽 WEB API。是否可以在 Vue.js 中获取本地主机上的数据?
【发布时间】:2019-08-20 16:18:18
【问题描述】:

我对 Vue.js 中的 GetUserStatsForGame 有疑问。 控制台中的警告:针对其他来源的资源的请求已被阻止。原因:CORS 标头“Access-Control-Allow-Origin”缺失。

正如您在我的代码中看到的那样,我有标题。警告应该会消失。

在 APIKEY 域中我尝试过: 本地主机 本地主机:8080 127.0.0.1 http://127.0.0.1/ http://localhost/ 还有更多……但什么都没有。

网络中的 GET 看起来不错:https://prnt.sc/n4jipf

      this.$axios
        .get(
          `http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v2/?appid=${
            this.appid
          }&key=${this.APIKEY}&steamid=76561198269391482&format=json`,
          {
            headers: {
              "Content-Type": "application/json",
              Accept: "application/json"
            }
          }
        )
        .then(r => {
          console.log(r);
        });

我想在前端显示来自 API 的数据,但在控制台“网络错误”中出现错误,数据未显示。

是否可以在 localhost 上显示数据?

【问题讨论】:

    标签: javascript vue.js get steam steam-web-api


    【解决方案1】:

    尝试使用此浏览器扩展程序,这解决了我在测试网站时遇到的类似问题:

    https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en

    【讨论】:

    • 它有帮助!数据显示
    猜你喜欢
    • 2020-05-15
    • 2016-07-13
    • 2014-11-27
    • 1970-01-01
    • 2021-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-18
    相关资源
    最近更新 更多