Wikipedia Project: Event Listeners + Fetch API

Hit a bit of a wall with this project. If I call the function apiCall by itself then it works fine, as soon as I try and add an Event Listener and then call the function apiCall then the fetch API doesn’t work at all.

For the record - I try and do all the projects using native JavaScript hence why I am not using any JQuery.

Link to project - https://codepen.io/Pagey/pen/wrZRqR

Any ideas why this is?

Was a very small thing that I was getting stuck on. I was using <input> for my Submit button which refreshed the page and so wouldn’t take the users’ text input. Simply changing that input button to a <button> made the project work. Now I just need to add styling and I’ll be done :slight_smile:

Funny. Randomly went on FCC forum yesterday for some “getting a developer job” motivation and read your post from early September. Then today I ran into almost this exact problem with a fetch call in an event listener, and your solution was the first one that popped up. Helped me realize the the input was in a tag and therefore not returning correctly.

1 Like

Haha thanks for sharing, I didn’t even post that much on the forum back then!