Accessing Wikipedia API elements


here’s my codepen

I’m trying to access “extract” of one of the objects, then to access them all through a for loop
as I don’t want to address the object by its name, I tried to use the brackets to access extract for object 0 but it returned undefined

example for the json data I’m talking about


If you add &formatversion=2 to your Wikipedia API URL, you will get the results back as an array of objects rather than an object with Page ID properties. It makes it a little more intuitive to loop through and get results based on what we’ve learned here at Free Code Camp.

'*&exlimit=20&exchars=200&format=json&gsrsearch=' + search

From looking at your CodePen, it seems you’ve figured out that a for…in loop works great regardless.


yeah, luckily I discovered this for in loop which was new to me, very handy.

I think I’m done with the project except for one issue that’s bothering me, the left side border on the results is not taking the full length, I’ve tried setting the border radius to 0 but I’m still having that issue


Add border-width: 0 to your .result class and it should fix that for you:

  color: #333;
  margin: 6px 10px;
  padding: 3px 15px;
  font-family: 'Raleway', sans-serif;
  border-width: 0;  
  border-left: 6px solid #548464;


so it was a pesky almost invisible border causing this, that worked, thank you!