NPM setup code has breaking issue which always returns error 500
albertothedev opened this issue · 1 comments
In the NPM package page, the code in the setup section has this:
var config = { app_id : "YOUR_OXFORD_ACCOUNT_APP_ID", app_key : "YOUR_OXFORD_ACCOUNT_APP_KEY", source_lang : "en" };
This always returns { status_code: 500, status_text: 'JSON Parse Failed' }
because since version 2 of the API english GB and US have separate dataset names. This can be seen in the code of the actual package, where the value for that variable is defaulted to en-us. It can be fixed by changing the value to "en-us" or "en-gb" in your index file.
The NPM page should be updated with this little correction in order to prevent people from encountering this silly mistake.
I also encountered this issue when using the dict.find() function. Changed the source_lang in config to "en-us" and it worked. However, I later used dict.inflections() with the "en-us" source_lang config and received status 500 error. Changed source_lang back to "en" and it worked. Not sure why this is the case, but something to keep in mind.