Answer the question
In order to leave comments, you need to log in
How to get an image from Wikipedia?
I found information on how to do a search on the wiki,
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
list: "search",
srsearch: "Nelson Mandela",
format: "json"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
if (response.query.search[0].title === "Nelson Mandela"){
console.log("Your search page 'Nelson Mandela' exists on English Wikipedia" );
}
})
.catch(function(error){console.log(error);});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question