Saturday, 15 February 2020

Need help with using a third-party API

Is it even called a "third-party API"?Anyway, in order to practice some React.js I am writing a little scrabble game application and I need to use an API to validate whether a given string is a word. For that, I have decided to use the Oxford Dictionary API. So far I have done:ran "npm install oxford-dictionary-api"got an id and a key for the APIcopied a snippet given on Oxford dictionary API website, it looks like thisconst Dictionary = require("oxford-dictionary-api");const dict = new Dictionary(app_id, app_key);dict.find("ace", function (error, data) { if (error) return console.log(error); console.log(data); });(of course, I have specified the id and the key)Created a shortcut to Chrome with disabled CORS (since cors was preventing the request fro being send).When I run it, I get 404 error:request.js:150 GET https://od-api.oxforddictionaries.com/api/v1/entries/en/ace 404 (NOT FOUND)Scrabble.js:27 No such entry foundOne reason for this could be that the Oxford dictionary has disabled v1 last year, so the request should be sent tohttps://od-api.oxforddictionaries.com/api/v2but I have no idea where to specify this. As you can see, my knowledge of working with APIs is extremely limited.I would appreciate any help! Also, if you know another API I could use for this.

Submitted February 15, 2020 at 01:05PM by learning_react

No comments:

Post a Comment