Created
March 21, 2018 20:49
-
-
Save ajess33/dc72dc51e7fedec5801a04e8bf535b62 to your computer and use it in GitHub Desktop.
Wikipedia Viewer json
This file contains 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 searchbar = document.querySelector('#searchbar'); | |
var searchButton = document.querySelector('#search'); | |
var results = document.querySelector('.results'); | |
var userInput = searchbar.value; | |
function fetchData() { | |
fetch( | |
'https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&gsrlimit=10&prop=extracts&pilimit=max&exintro&explaintext&exsentences=2&exlimit=max&gsrsearch=' + | |
userInput | |
) | |
.then(response => response.json()) | |
.then(jsonData => { | |
var myData = jsonData.query.pages; | |
console.log(myData); | |
for (result in myData) { | |
console.log(result); | |
} | |
}); | |
} | |
fetchData(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment