This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function handleRequest(){ | |
| console.log(JSON.parse(request.responseText)); | |
| } | |
| var url; | |
| url = "https://api.unsplash.com/search/photos/?query=home"; | |
| var request = new XMLHttpRequest(); | |
| request.onreadystatechange = handleRequest; | |
| request.open('GET',url,true); | |
| request.setRequestHeader('Authorization','Client-ID Your-client-id-here'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var ajaxRequest = new XMLHttpRequest(); | |
| ajaxRequest.onreadystatechange = handleRequest; | |
| ajaxRequest.open('GET','https://api.unsplash.com/photos/?client_id=b14e32fb4fef48a669291db40c3cbb7797701501d9a453c3da8fcf5df3c77470', true); | |
| ajaxRequest.send(); | |
| function handleRequest(data){ | |
| console.log(data.responseText); | |
| } |
NewerOlder