EventRegistry / event-registry-node-js

Node.js package for API access to news articles and events in the Event Registry
MIT License
13 stars 2 forks source link

Event registry with nodejs not working #11

Closed gaganjotkaur3197 closed 4 years ago

gaganjotkaur3197 commented 4 years ago

I am using Event registry library in my nodejs application. I am using the node version v8.16.0. I am trying to run the code samples mentioned in the documentation as

var erBase = require("eventregistry");
var er = new erBase.EventRegistry({ apiKey: 'EVENT_REGISTRY_API_KEY' });
er.getConceptUri("George Clooney").then((conceptUri) => {
                console.log(conceptUri);
                var q = new erBase.QueryArticlesIter(er, {conceptUri: conceptUri, sortBy: "date"});
                q.execQuery((item) => {
                    console.info(item);
                })
            }).catch((err) => {
                console.log(err);
            });

I am getting the below error everytime

TypeError: Cannot read property 'data' of undefined
    at EventRegistry.<anonymous> (/var/www/html/MP-latest/Latest/mindpeer/containers/intelstreams/node_modules/eventregistry/dist/eventRegistry.js:367:55)
    at step (/var/www/html/MP-latest/Latest/mindpeer/containers/intelstreams/node_modules/eventregistry/dist/eventRegistry.js:43:23)
    at Object.next (/var/www/html/MP-latest/Latest/mindpeer/containers/intelstreams/node_modules/eventregistry/dist/eventRegistry.js:24:53)
    at fulfilled (/var/www/html/MP-latest/Latest/mindpeer/containers/intelstreams/node_modules/eventregistry/dist/eventRegistry.js:15:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
UnspokenMallard commented 4 years ago

Hi,

I've had some problems reproducing your issue. This happens if the verbose output is turned off, and the request fails. I've issued a small update which improves error messages.

Please run npm update eventregistry, then modify example as seen below:

var erBase = require("eventregistry");
var er = new erBase.EventRegistry({ apiKey: 'EVENT_REGISTRY_API_KEY', verboseOutput: true });
er.getConceptUri("George Clooney").then((conceptUri) => {
                console.log(conceptUri);
                var q = new erBase.QueryArticlesIter(er, {conceptUri: conceptUri, sortBy: "date"});
                q.execQuery((item) => {
                    console.info(item);
                })
            }).catch((err) => {
                console.log(err);
            });

Check the 'http://eventregistry.org/me?tab=settings' to obtain the correct API key for your account.

Best regards, Anze

gaganjotkaur3197 commented 4 years ago

Thanks, Anze. it will surely help me.