Hello . I can not get normal json data. The information what I receive is not complete.
My code
document.getElementById('search').addEventListener('click',function(val){
let userInput = document.getElementById('userInput');
let term = userInput.value;
let wikiRequest = new XMLHttpRequest();
let url = 'https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=god&origin=*&format=json';
wikiRequest.open('GET', url)
wikiRequest.onload = function() {
let data = JSON.parse(wikiRequest.responseText);
let array = data.query.search;
for(var i= 0; i < array.length; i++){
let output = document.getElementById('output');
output.insertAdjacentHTML('beforeEnd', '<h3>'+array[i].title+'</h3>' + '<p>'+ array[i].snippet +'</p>' );
// console.log(array[i]);
}
console.log(data);
}
wikiRequest.send();
} )
i think problem is in parameters of wiki api what i pointed out. I will be very grateful for any help.