-
-
Save azamsharp/fca061ea0842366c7c2ff5972c59f4b1 to your computer and use it in GitHub Desktop.
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
// http://www.omdbapi.com/?s=superman&apikey=564727fa | |
// create a new XMLHTTPRequest object which will allow to make a request to the server | |
let request = new XMLHttpRequest() | |
// hook event listener for load event so I can get the data when the request is finished | |
request.addEventListener("load",function() { | |
// "this" is a XMLHttpRequest object | |
// console.log(this.responseText) | |
// JSON.parse is going to convert valid JSON string to a JS object | |
let result = JSON.parse(this.responseText) | |
// iterate | |
for(let index = 0; index < result.Search.length; index++) { | |
console.log(result.Search[index].Title) | |
} | |
// console.log(result) | |
}) | |
// setting up the type of the request and the url of the request | |
request.open("GET","http://www.omdbapi.com/?s=superman&apikey=564727fa") | |
// get weather information | |
//request.open("GET","http://api.openweathermap.org/data/2.5/weather?q=houston&appid=7d2dd8c9c5578b741c7735ad3f0d39ea") | |
// send the request to the server | |
request.send() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment