Wikipedia api native javascript

Hello . I can not get normal json data. The information what I receive is not complete.

My code

    let userInput = document.getElementById('userInput');
    let term = userInput.value;
    let wikiRequest = new XMLHttpRequest();
    let url = '*&format=json';'GET', url)
    wikiRequest.onload = function() {
        let data = JSON.parse(wikiRequest.responseText);
        let array =;
        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]);
} )

i think problem is in parameters of wiki api what i pointed out. I will be very grateful for any help.

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


When I run your code, I get a JSON data. What format are you wanting to get exactly?

Hi, I want to receive full information about term what i searching for .

The task is completed. Sorry my mistake. How can I close this topic?


function Wiki(lang){
	this.lang = lang || "fr";
	this.inuse = false;
Wiki.prototype.research = function(s, callback){
		console.error("Wiki est déjà en cours d'utilisation !");
	} else {
		this.inuse = true;
		let r = new XMLHttpRequest();
		r.onload = function(){
			Wiki.prototype.inuse = false;
			let j = JSON.parse(r.responseText);
		}'GET', "https://" + this.lang +"*&profile=normal&search="+encodeURIComponent(s));

var c = new Wiki();
c.research("Victor Hugo", function(result){