I’m working on the twitch project, trying to implement an additional feature using twitch’s search api, pen here and I keep getting “Not Found” error. I’m using a callback function in the url to handle CORS (from what I’ve researched that should handle it) but to no resolution. If I paste the url to my browser address bar I get “Bad Request” but without the “callback=?” I do get the JSON I expect. Furthermore, I am able to get non-search api results that I expect using callback=? in the url (which seems to support that
CORS is being handled).
Search api url example: https://api.twitch.tv/kraken/search/streams?q=world_of_warcraft&callback=? (doesn’t work in codepen with or without the callback=? ending, works in browser without.)
Other api url example: https://api.twitch.tv/kraken/streams/freecodecamp? (works in codepen with the callback=? ending, works in browser without.)
p.s. When you check the pen, the portion of the code pertaining to this question may be commented out so I can move on with the basic project in the meanwhile. The comment will start with “SEARCH”. Just uncomment to test the error/solutions.
Thanks for any help!
Edit: With the help of the twitch forums, I found the solution to my problem. Just to pass on the bit I found most helpful: My problem was discovered using the Network tab of the developer tools which revealed the url wasn’t being passed to getJSON. That and I wasn’t correctly accessing the JSON object.