Steam WEB API。是否可以在Vue.js中获取localhost上的数据?

问题描述 投票:0回答:1

我在Vue.js中遇到GetUserStatsForGame的问题。控制台中的警告:已阻止其他来源的资源的请求。原因:缺少CORS标题“Access-Control-Allow-Origin”。

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

在APIKEY域我试过:localhost localhost: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个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.