I am trying to retrieve pictures from imgur to display on my blog by using an ajax request in jQuery
$.ajax({
type: "GET",
url: "https://api.imgur.com/3/image/kvM6pxn.json",
dataType: "jsonp",
beforeSend: function(xhr) {
xhr.setRequestHeader('Authorization', 'Client-ID <client-id>');
},
success: function(data) {
console.log(data);
}
});
but I am getting a 401 unauthorized error. Can anyone tell me what I am doing wrong? Thanks
Changing
dataType
fromjsonp
tojson
fixed it. Not really sure why though...