0

I'm having trouble getting my Javascript program to access a free English Dictionary API called OwlBot: https://owlbot.info/

Here's what I tried (https://jsfiddle.net/85w03162/3/):

    $.getJSON("https://owlbot.info/api/v1/dictionary/owl?format=json?callback=?",function(json){
        console.log("This is the JSON output by the OwlBot API: ");
        console.log(json);
    });

As you can see from the fiddle, this code works for the Github API, but fails for my OwlBot API. The Firebug lite console in jsfiddle says the callback function returns undefined, while the Chrome console gives the following error:

enter image description here

I'm new to cross-domain requests, so any pointers would be much appreciated. I've looked at the other answers on StackOverflow and elsewhere, but nothing seems to apply.

Other Info

OwlBot allows me to make GET requests on the API in JSON format, so this is the output I'm expecting from https://owlbot.info/api/v1/dictionary/owl?format=json :

[{"type":"noun","defenition":"a nocturnal bird of prey with large eyes, a facial disc, a hooked beak, and typically a loud hooting call.","example":"I love reaching out into that absolute silence, when you can hear the owl or the wind."}]

I can also curl this from the Terminal, no problem (curl https://owlbot.info/api/v1/dictionary/owl), but can't for the life of me figure out how to access this object in Javascript.

Community
  • 1
  • 1
JP Lew
  • 4,121
  • 2
  • 32
  • 45
  • 1
    You probably meant `?format=json&callback=?` (note the "&", not another "?") but that's not going to help you because the API does not support JSONP nor is it set up for CORS – Phil Aug 29 '17 at 00:25
  • ok, thank you for the response. Any idea how to go about accessing the API without JSONP or CORS? – JP Lew Aug 29 '17 at 00:36
  • 1
    I've linked another post with some very good answers – Phil Aug 29 '17 at 00:38
  • you're right, it's working using http://www.ajax-cross-origin.com/, which I found on the answer you linked. Cheers friend! – JP Lew Aug 29 '17 at 00:45

0 Answers0