Lissy93 / twitter-sentiment-visualisation

🌍 Sentiment analysis over real-time social media data, rendering live charts to visualise trends
211 stars 68 forks source link

Issue with routes #12

Closed akashdave11 closed 7 years ago

akashdave11 commented 7 years ago

@Lissy93

The search term page seems to be working fine with the sentiment summary. However any link from the search page for eg - Word cloud, entity extraction, Raw tweets and even searching again from the same page gives the same exact error

POST /api/db 200 107.876 ms - 3807 C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\routes\entity-api.js:21 ref = Object.keys(data); ^

TypeError: Cannot convert undefined or null to object at formatData (C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\routes\entity-api.js:21:18) at C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\routes\entity-api.js:37:23 at Request._callback (C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\node_modules\haven-entity-extraction\index.js:64:16) at Request.self.callback (C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\node_modules\request\request.js:188:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\node_modules\request\request.js:1171:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage. (C:\New folder (2)\Wiki article\twitter-sentiment-visualisation\node_modules\request\request.js:1091:12) at IncomingMessage.g (events.js:291:16) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! twitter-sentiment-visualisation@0.0.1 start: node ./bin/www npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the twitter-sentiment-visualisation@0.0.1 start script 'node ./bin/www'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the twitter-sentiment-visualisation package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node ./bin/www npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs twitter-sentiment-visualisation npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls twitter-sentiment-visualisation npm ERR! There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\atul dave\AppData\Roaming\npm-cache_logs\2017-04-27T16_44_52_078Z-debug.log

Lissy93 commented 7 years ago

Is it just the entity-api that this is happening for? I am having trouble debugging this, as it works ok for me. Can you try tracing through the error? I can see from the above output that the data from the HP API at some point has become undefined

akashdave11 commented 7 years ago

@Lissy93 Yes its happening for entity.api only. The url request for hp seems fine to me. Could be issue with the package?

ianmyles commented 7 years ago

I was getting this error as well. Check that your /server-side-source/config/keys.coffee looks like this:

https://github.com/Lissy93/twitter-sentiment-visualisation/blob/dev/server-side-source/config/sample-keys.coffee

And that your keys.js looks something like this: (function() { exports.twitter = { consumer_key: 'XXXXXXXXXXXXXXXXXXXXXXXXX', consumer_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', token_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' }; exports.watson = { username: 'XXXXXXXXXXXXXXXXXXXXXXXXX', password: 'XXXXXXXXXXXXXXXXXXXXXXXXX' }; exports.hp = { 'XXXXXXXXXXXXXXXXXXXXXXXXX' }; }).call(this);

I think it has something to do with your havenondemand key specifically.

akashdave11 commented 7 years ago

@ianmyles

Yup seem no issue with them except for the curly parenthesis around exports.hp. Does it matter?

Were you also getting the same error on entity.api regarding haven entity extraction?

ianmyles commented 7 years ago

Yes I was getting the same error exactly. The extract above is from the keys.js file and this needs to look the same (with parenthesis). I copied it from my local working version and removed the key values. If that doesn't work let me know.

akashdave11 commented 7 years ago

@ianmyles

Unfortunately it didn't work. Instead on putting brackets it gives me an error for them. Have you made you any other changes? If possible can you drive me your local version to see if that one works on mine? Then maybe i'll be able to work out what the issue is. In the meantime i'll try and get a new HP api key and see if thats the issue.

ianmyles commented 7 years ago

Sorry, @akashdave11 I pasted in the wrong code. You were right the brackets are unnecessary. This is what I have:

(function() { exports.twitter = { consumer_key: 'XXXXXXXXXXXXXXXXXXXXXXXXX', consumer_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXX', token: 'XXXXXXXXXXXXXXXXXXXXXXXXX', token_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXX' };

exports.googlePlaces = 'XXXXXXXXXXXXXXXXXXXXXXXXX';

exports.hp = 'XXXXXXXXXXXXXXXXXXXXXXXXX';

exports.watson = { username: 'XXXXXXXXXXXXXXXXXXXXXXXXX', password: 'XXXXXXXXXXXXXXXXXXXXXXXXX' };

}).call(this);

akashdave11 commented 7 years ago

@ianmyles

Yup the brackets dont seem to be an issue. And the format for both keys.coffee and keys.js remain the same. Since you had the same error what changes did you make?

ianmyles commented 7 years ago

My keys.coffee looks like this (in server-side-source/config):

exports.twitter = consumer_key : 'XXXXXXXXXXXXXXXXXXXXXXXXX' consumer_secret : 'XXXXXXXXXXXXXXXXXXXXXXXXX' token: 'XXXXXXXXXXXXXXXXXXXXXXXXX' token_secret: 'XXXXXXXXXXXXXXXXXXXXXXXXX'

exports.googlePlaces = 'XXXXXXXXXXXXXXXXXXXXXXXXX'

exports.hp = 'XXXXXXXXXXXXXXXXXXXXXXXXX'

exports.watson = username: 'XXXXXXXXXXXXXXXXXXXXXXXXX' password: 'XXXXXXXXXXXXXXXXXXXXXXXXX'

I'll double check if i changed anything else but I was almost sure this error was thrown because it coluldn't get the key from the config file.

Lissy93 commented 7 years ago

Just to confirm, you only need to modify the coffee file, so as long as that's correct don't need to worry about brackets.

@akashdave11 sounds like an issue with your API key, have you checked it's definently correct?

akashdave11 commented 7 years ago

@Lissy93

I created a new Api key and also updated the haven module. Now it seems to working just fine. Thanks for pointing out the error. Not sure what seemed to trigger it though.