Stuck on Wikipedia viewer project

Hey guys, i am stuck on the Wikipedia viewer. So the problem is that i get an error when the function renderHTML(wikiDataSave); is called. The code looks as it should be but i can’t figure out where i am making mistake. Please help!!!

Feel free to download the code and test it in your browsers.
Thanks

Just taking a quick glance at your code, it doesn’t look like query is defined anywhere. Did you perhaps mean data.query.search?

1 Like

Hey @ivanilievski,
I noticed a couple of things when I tried to run your code:

  1. Your HTML markup in CodePen does not have the tags for html, head or body
  2. The type of your input with id src has a typo. You wrote tetx instead of text.
  3. In your renderHTML function, in your for loop declaration, you are using the query variable without ever declaring it. :warning:
function renderHTML(data){
  var htmlTitle = "";
  
  for (var i=0; i<query.search.length;i++){ // <----- Where is query declared?
    htmlTitle = "<p>"+ query.search.title[i] +"</p>"; 
  }
  
  
  listSearch.insertAdjacentHTML("beforeend", htmlTitle);
}

Hope that helps :

1 Like