msananikone
4 years agoNew Member
Basic auth in simple Ajax code
I am trying to make a very simple API call using Ajax. I can change the headers in Python, but can't seem to make it work with Ajax. It may be simple, as I am just getting started with this kind of coding.
Curl statement:
curl -X GET "myapiurl" -H "accept: text/plain" -H "authorization: Basic myauthenticationkey="
$(document).ready(function(){
$.ajax({
type: "GET",
url: "myapiurl",
headers: {"Authorization": "Basic myauthenticationkey="}
})
$.ajax({
type: "GET",
url: "myapiurl",
headers: {"Authorization": "Basic myauthenticationkey="}
})
});