I have an ajax request that looks like the following:
$.ajax({
url: 'https://api.imgur.com/3/image',
type: 'post',
headers: {
Authorization: 'Client-ID XXXXXX'
},
data: {
image: img,
title: 'test'
},
dataType: 'json',
success: function(response) {
if(response.success) {
url = response.data.link;
return url;
}
}
});
However, this is dependent on jQuery. I would like to know how to write a pure javascript implementation of this.
I have the following code so far, but I'm not sure what to do next...
xmlhttp.open("POST","https://api.imgur.com/3/image",true);
xmlhttp.setRequestHeader("Content-type","application/json");
How can I integrate the data and the callbacks into this?
Thanks