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

when fetching it's giving CORS error #131

Open naveenkash opened 4 years ago

naveenkash commented 4 years ago

so i'm using this method in mounted in vue and giving me cors error .

googleTrends.realTimeTrends(
  {
    geo: "US",
    category: "all"
  },
  function(err, results) {
    if (err) {
      console.log(err);
    } else {
      console.log("trends", results);
    }
  }
);

this is the error

Access to fetch at 'https://trends.google.com/trends/api/realtimetrends?hl=en-US&tz=-330&geo=US&cat=all&fi=0&fs=0&ri=300&rs=20&sort=0' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

juliazxu commented 4 years ago

I am getting the same error

juliazxu commented 4 years ago

Figured it out, it says in the documentation that it can't be used client side.