google-trends-api icon indicating copy to clipboard operation
google-trends-api copied to clipboard

[TypeError: undefined is not a function]

Open danbradster opened this issue 5 years ago • 0 comments

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\":[]}}"

danbradster avatar Apr 25 '20 07:04 danbradster