I'm working with some API points set-up to grab data. The first end point I have to hit returns an auth code, which to be passed into the rest of the calls header.
I seem to have issues hitting first call with ajax
and it works well with postman
. I keep getting back errors, but no message.
Am I setting this up properly? It's using oauth2 and I don't have any experience with that.
A jsfiddle example https://jsfiddle.net/7f5dgn08/
var url = 'http://webaddress';
$.ajax({
type: "oauth2",
url: url,
cache: false,
async: true,
crossDomain: true,
headers: {
username: "username",
password: "pass"
},
dataType: "json",
success: function (data) {
localStorage.setItem('aCode', JSON.stringify(data))
},
error: function (jqXHR, exception) {
console.log(jqXHR.responseJSON);
}
});