Im using javascripte and im trying to make a simple ajax request using an url from an api .When I open the page it returns me: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. I don't know how to fix the error, I have been trying some things but they didnt work for me. Im using: chrome. Hope you can help me. Here is the code:
$.ajax({
url: 'https://brokersports.ddns.net/api/v2/basketball/inlive/',
type: 'GET',
contentType: 'application/json',
headers: {
"Authorization": "Bearer my-api-key"
},
success: function (data) {
console.log(data);
$.each(data.matches, function( index, value ) {
var league ='<tr id="live"><td id="time">'+ value.live.status+'</td><td id="equi">'+value.match+'</td><td id= "score">'+value.live.score+'</td>';
$.ajax({
url: 'https://brokersports.ddns.net/api/v2'+value.url+'/1X2/531',
contentType: 'application/json',
headers: {
"Authorization": "Bearer my-api-key"
},
success: function (data) {
console.log(data);
$.each(data.dataLive, function( index, value ) {
var match ='<td id="odd"><button id=btn>'+ data.dataLive[0].odds[0]+'</button></td><td id="odd"><button id=btn>'+ data.dataLive[0].odds[1]+'</button></td><td id="odd"><button id=btn>'+ data.dataLive[0].odds[2]+'</button></td><td id="odd"><button id=btn>+plus</button></td></tr>';
$('#basketlive').append(league+match);
});
},
error: function (error) {
}
});
});
},
error: function (error) {
}
});