<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<title>Sample Page</title>
<script>
var summonername = "TraversTT"
var api_key1= "******"
var headers1 = {
'Access-Control-Allow-Origin': '*',
'Origin': "https://developer.riotgames.com",
'Accept-Charset': "application/x-www-form-urlencoded; charset=UTF-8",
'X-Riot-Token': "*****",
'Accept-Language': "en-US,en;q=0.9",
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
}
var settings = {
"async": true,
"type": "POST",
"url": "https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/"+summonername+"?api_key="+api_key1,
"headers": headers1,
"dataType": 'json',
"data": 'dataTest',
};
$.ajax(settings).done(function (response) {
console.log(response);
});
I am getting constant errors connecting to this API and getting a response other than:
jquery.min.js:4 Refused to set unsafe header "Origin" send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 jquery.min.js:4 Refused to set unsafe header "Accept-Charset" send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 jquery.min.js:4 Refused to set unsafe header "User-Agent" send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 2jquery.min.js:4 OPTIONS https://na1.api.riotgames.com/lol/summoner/v4/summoners/by- name/TraversTT?api_key=RGAPI-1ed86c58-2eee-4e6c-85d4-3bead97e4d3b 405 (Method Not Allowed) send @ jquery.min.js:4 ajax @ jquery.min.js:4 (anonymous) @ Riot dDragon access sample2.html:26 Riot dDragon access sample2.html:1 Access to XMLHttpRequest at 'https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/TraversTT? api_key=RGAPI-1ed86c58-2eee-4e6c-85d4-3bead97e4d3b' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.`
I've been playing with different ways of doing this today for like 6 hours so any help available would be amazing.