Codepen JSON issues?

I completed the Random Quotes and Local Weather projects over the past couple weeks and have recently begun working on the WikiViewer. After immense trouble with JSON and assuming that it may be an API issue with wikipedia.org, I check out my previously working projects, only to find them non-functional.

Anyone else experiencing such issues or have I somehow accidentally altered my code or settings?

Thanks!

P.S. If it’s relevant, the only change to my Chrome browser has been the ‘Postman’ add-on.

Are you using http or https on codepen?

Alternatively are you using crossorigin.me? As that service frequently goes down.

If you’re using crossorigin.me, replace it with https://cors-anywhere.herokuapp.com

2 Likes

HTTPS, as per being informed by another user (as HTTP failed to work back when I first began coding the projects). I was indeed using crossorigin successfully- seems like it now returns “Origin: header is required” for some reason.

On a side note, my bigger issue is that no commands seem to work within my JSON request, at least with regards to the wiki API. (“https://en.wikipedia.org/w/api.php?action=opensearch&search=” + input + “&limit=10&namespace=0&format=json”)

Edit: Will check out cors-anywhere

Edit #2 - I’ll start investing header origins more in depth. Until then, https://cors-anywhere.herokuapp.com seems to solve the issue, but only intermittently returns objects via the wiki API. Thanks!

For displaying search results from the wiki API I’ve been using “action=query&list=search”, google “search wiki API” for more details.

I found it incredibly confusing at first but got there in the end!

The Same thing is happening with me… Even my weather app is not working which i created two months ago. Anyone can help?

Are you using crossorigin.me?

yup.i am using cross origin.me link https://codepen.io/shwetarajput012/pen/kXqPvy

I was previously using that, but ended up using action=opensearch&search= because of issues and not being able to limit the search to top 10. I was using crossorigin, but have now been switching between https://cors.now.sh and herokuapp.com.

Sadly, it seems as though both of them are a hit or a miss when it comes to fetching and returning the JSON data via a console.log();.

. Thanx a lot. U solved a huge problem. I am going to submit my project in my college. Thanx a lot.

Use “srlimit=yournumber” to limit search results

You shouldn’t need to use any external cross origin site with the wiki API, as it allows https requests