pat310 / google-trends-api

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

topRelated call must have a timePeriod object #41

Closed DWboutin closed 7 years ago

DWboutin commented 7 years ago

In the README.md, it's says that it's optionnal, but i got this:

Error: timePeriod must be an object of type {type: enum, value: number}
at module.exports (/Users/name/Desktop/apiproject/node_modules/google-trends-api/lib/resources/timePeriodConverter.js:7:105)
at parseArguments (/Users/name/Desktop/apiproject/node_modules/google-trends-api/lib/resources/callbacks.js:37:25)
at Object.request [as topRelated] (/Users/name/Desktop/apiproject/node_modules/google-trends-api/lib/utils/topRelated.js:9:12)
at /Users/name/Desktop/apiproject/src/entities/GoogleTrends.js:19:20
at GoogleTrends.topRelated (/Users/name/Desktop/apiproject/src/entities/GoogleTrends.js:18:12)
at /Users/name/Desktop/apiproject/src/server.js:38:16
at Layer.handle [as handle_request] (/Users/name/Desktop/apiproject/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/name/Desktop/apiproject/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/name/Desktop/apiproject/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/name/Desktop/apiproject/node_modules/express/lib/router/layer.js:95:5)
at /Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:330:12)
at next (/Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:271:10)
at jsonParser (/Users/name/Desktop/apiproject/node_modules/body-parser/lib/types/json.js:103:7)
at Layer.handle [as handle_request] (/Users/name/Desktop/apiproject/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:312:13)
at /Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:280:7
at Function.process_params (/Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:330:12)
at next (/Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:271:10)
at expressInit (/Users/name/Desktop/apiproject/node_modules/express/lib/middleware/init.js:33:5)
at Layer.handle [as handle_request] (/Users/name/Desktop/apiproject/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/Users/name/Desktop/apiproject/node_modules/express/lib/router/index.js:312:13)
Dayjo commented 7 years ago

Hi @DWboutin,

Could you please show us your code so that we can see how you're using it?

DWboutin commented 7 years ago

You can close it, i just misunderstand how it works!

But how the {type: 'day', value: number} Works? Should i put 20170203 for the day?

Dayjo commented 7 years ago

Hello @DWboutin,

No problem, the number represents how many days you want the time period to be (From today), so if you set it to 5, it will look at the last 5 days.

See; https://github.com/pat310/google-trends-api/blob/eca1ce15e12099f824589656c3691bdf2207c82f/README.md#example-2

DWboutin commented 7 years ago

Ho great! I was think it was for a date.

Do you think the README.md will explain it better?

2017-02-03 11:46 GMT-05:00 Joel notifications@github.com:

Hello @DWboutin https://github.com/DWboutin,

No problem, the number represents how many days you want the time period to be (From today), so if you set it to 5, it will look at the last 5 days.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pat310/google-trends-api/issues/41#issuecomment-277298573, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQsFs0i_SoboU1AAj04YXLlJMPGEa14ks5rY1n9gaJpZM4K_ur5 .

-- Mikaël Boutin Développeur web "front-end" Twitter : @DWboutin http://twitter.com/#%21/DWboutin Github : DWboutin https://github.com/DWboutin LinkedIn: https://ca.linkedin.com/pub/mikael-boutin/27/732/b47

(581) 999-1252

Dayjo commented 7 years ago

This tries to explain it in the README.md here;

The following example provides the historical trend data for 'OJ Simpson' for the past 5 days. Optionally, the input could have been provided as googleTrends.trendData('OJ Simpson', {type: 'day', value: 5}).

DWboutin commented 7 years ago

Ho nice, i just didn't read for trendData