pat310 / google-trends-api

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

Error in version 4.0.0 #48

Closed Dayjo closed 7 years ago

Dayjo commented 7 years ago

Hello!

Just running the example code;

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

googleTrends.interestOverTime({keyword: 'Valentines Day'})
.then(function(results){
  console.log(results);
})
.catch(function(err){
  console.error(err);
});

Getting the following error;


TypeError: Cannot read property 'toUpperCase' of undefined
    at /google-trends/node_modules/google-trends-api/lib/google-trends-api.min.js:1:3609
    at Array.some (native)
    at s (/google-trends/node_modules/google-trends-api/lib/google-trends-api.min.js:1:3580)
    at u (/google-trends/node_modules/google-trends-api/lib/google-trends-api.min.js:1:3869)
    at Object.interestOverTime (/google-trends/node_modules/google-trends-api/lib/google-trends-api.min.js:1:2235)
    at Object.<anonymous> (/google-trends/test.js:3:14)
    at Module._compile (module.js:556:32)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.runMain (module.js:590:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

I'm assuming it's something to do with;

image

Dayjo commented 7 years ago

Just as a side note, I wanted to try and build it myself with a fix, but when I run npm run start or npm run dev, I get the following response;

> google-trends-api@4.0.0 start /google-trends/node_modules/google-trends-api
> npm run dev

> google-trends-api@4.0.0 dev /google-trends/node_modules/google-trends-api
> webpack --progress --colors --watch --mode=dev

Hash: cbb9eab0f38384aa33b7
Version: webpack 1.12.9
Time: 55ms
    + 1 hidden modules

ERROR in ./src/index.js
Module parse failed: /google-trends/node_modules/google-trends-api/src/index.js Line 3: Unexpected token
You may need an appropriate loader to handle this file type.
| 'use strict';
|
| import api from './api';
|
| export default {

Feel free to laugh if I've done something stupid ^_^ ( I did run npm install )

pat310 commented 7 years ago

Hmm, what version of node are you using?

Dayjo commented 7 years ago

Looks like I'm on 6.7.0 I can try updating to the latest LTS 6.9.5.

Edit; updated, and getting the exact same errors.

pat310 commented 7 years ago

Should work on 6.7.0 must be something else...

Dayjo commented 7 years ago

Have tried from scratch again (still on 6.9.5 now);

mkdir google-trends-test
cd google-trends-test

Install (it's going up a directory because I don't have a package.json, I also tried it with one so it installs in this directory)

npm install google-trends-api
/Users/joelday/Sites
└── google-trends-api@4.0.0

npm WARN enoent ENOENT: no such file or directory, open '/Users/joelday/Sites/package.json'
npm WARN Sites No description
npm WARN Sites No repository field.
npm WARN Sites No README data
npm WARN Sites No license field.
nano example.js

Put in;

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);
});
node example.js

Exact same error :( let me know if there's anything else I can try.

pat310 commented 7 years ago

Ah not sure why it's not working, I'll have to poke around a bit later. Maybe try and change the package.json main key to lib/google-trends-api.js rather than lib/google-trends-api.min.js on the downloaded node module

pat310 commented 7 years ago

@Dayjo Ok, so I forgot to npm run build before deploying. 😬 Should work now in v4.0.1

Dayjo commented 7 years ago

Hehe whoops!

Works a treat! :) Time to bombard it requests.