pat310 / google-trends-api

An API layer on top of google trends
https://www.npmjs.com/package/google-trends-api
MIT License
874 stars 174 forks source link

[TypeError: undefined is not a function] #136

Open danbradster opened 4 years ago

danbradster commented 4 years ago

Sorry for the noob question. It's my first time in Node from PHP usually. I put Node onto a subdomain, to not break my PHP site.

I have app.js with contents:

const googleTrends = require('google-trends-api');

googleTrends.interestOverTime({keyword: 'Women\'s march'})
.then(function(results){
  console.log('These results are awesome', results);
})
.catch(function(err){
  console.error('Oh no there was an error', err);
});

I have /public/index.php - blank file. I have /node_modules/google-trends-api/ - from installing it.

I run 'node app.js' on the command line, then:

Oh no there was an error [TypeError: undefined is not a function]

The code seems to be working in https://npm.runkit.com/google-trends-api, but I can't get it to work on my Dreamhost VPS. On RunKit it outputs this:


Promise (resolved)
Promise undefined
"These results are awesome"
"{\"default\":{\"timelineData\":[{\"time\":\"1072915200\",\…edValue\":[\"<1\"],\"isPartial\":true}],\"averages\":[]}}"