What's wrong with my wikipedia viewer

I don’t know what to do. It says [object object] when I try to get it to work what should I do. Do I need to change
what var title equals.

Hello,

You need to stringify the return object in order to view it correctly.

document.write(JSON.stringify(result.query.pages));

This will show the data returned in the way you want.However the data that your API returns seems complicated.

Try to use below API which returns data in a simple structure.

"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=" + search term goes here + "&callback=?"

Use your browsers console to check weather each step of your code is working.

This will make your life easier.

Regards,
Sachithra.