我如何在 javascript 中访问 Riot api

问题描述

每次我运行这段代码时:

async function Summoner_V4(region,summonerName) {
    const url = `https://${region}.api.riotgames.com/lol/summoner/v4/summoners/by-name/${summonerName}?api_key=${api_key}`;
    const response = await fetch(url);
    const data = await response.json();
    return data
}

我有 3 个错误

错误 1:

Access to fetch at 'https://euw1.api.riotgames.com/lol/summoner/v4/summoners/by-name/Monkvy?api_key={myapikey}' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs,set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

错误 2:

Failed to load resource: net::ERR_Failed

错误 3:

Uncaught (in promise) TypeError: Failed to fetch

请heeeelp我不知道该怎么办

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)