Allow-Control-Allow-Origin HTTP Status 401

0

my error is as follows:

  

Failed to load    link :   No 'Access-Control-Allow-Origin' header is present on the requested   resource. Origin 'null' is therefore not allowed access. The response   had HTTP status code 401.

My code is as follows:

function onClick() {

	var api = "https://euw1.api.riotgames.com/lol/summoner/v3/summoners/by-name/";
	var apiKey = "?RGAPI-276acd60-2264-4c3e-aa5e-17333c48ab70";
	var query = document.getElementById("summoner").value;
	var fullKey = api + query + apiKey;

	var xhr = new XMLHttpRequest();
	xhr.open('GET', fullKey, true);
	xhr.send();

	xhr.onreadystatechange = processRequest;

	function processRequest(e) {
		if (xhr.readyState == 4 && xhr.status == 200) {
			var response = JSON.parse(xhr.responseText);
		}
		document.getElementById("span").innerText = response.accountId;
	}
}
<!DOCTYPE html>
<html>
<head>
	<title>DSFSF</title>
</head>

<script type="text/javascript" src="java.js"></script>


<body>

<h2>API KAPPAEQUISCU</h2>
<h3>Summoner:</h3>

<input type="text" id="summoner">
<input type="submit" onclick="onClick();">

<h3>SummonerID:</h3>
<span id="span">

</span>
<span id="spanDos">

</span>

</body>
</html>
    
asked by Kappaequiscu 27.10.2017 в 20:25
source

0 answers