I am trying to pull data from an api using jquery but I am receving an error
Failed to load resource: the server responded with a status of 401 (Unauthorized)
I have set the url as follows
url: "https://jsonodds.com/api/odds/soccer"
and I've tried setting the header two different ways,
firstly
headers: {
'JsonOdds-API-Key', key
}
and also using the beforesend function
beforeSend: function (xhr) {
xhr.setRequestHeader("JsonOdds-API-Key", key);
}
I already have my key defined. I have tested the url and header on postman and it returns data could it be a problem with other code I have wrote?