Skip to content

Instantly share code, notes, and snippets.

@vickonrails
Last active October 31, 2017 04:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vickonrails/b40918135c4fd48f2e248b695d873a03 to your computer and use it in GitHub Desktop.
Save vickonrails/b40918135c4fd48f2e248b695d873a03 to your computer and use it in GitHub Desktop.
function handleRequest(){
if(this.readyState == 4 && this.status == 200){ //Explain this in a bit.
console.log(JSON.parse(request.responseText));
}
}
var url;
url = "https://api.unsplash.com/search/photos/?query=home"; //We are searching for the query home.
var request = new XMLHttpRequest();
request.onreadystatechange = handleRequest;
request.open('GET',url,true);
request.setRequestHeader('Authorization','Client-ID your-client-id'); // Unique client ID.
request.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment