I am using google trends API to eventually export trends data to an excel file. The issue is I want to extract ONLY the formattedTime and value for my keywords. While Ive tried to do this, I've also noticed that results are not being pulled properly. For instance, when I try to push results from the API to an empty dictionary, I continue to get an empty array.
Any idea?
Thank you.
'use strict';
const googleTrends = require('google-trends-api');
var something = [];    
    googleTrends.interestOverTime({
        keyword: 'animals',
        startTime: new Date(Date.now() - (1 * 60 * 60 * 1000)),
        granularTimeResolution: true,
    }, function(err, results) {
        something.push(results);
        if (err)
            console.log('oh no error!', err);
        else
            console.log("--------------------------")
    });
console.log(something);
Example of Data Pulled:
{
  "default": {
     "timelineData":[
       {
         "time":"1511629200",
         "formattedTime":"Nov 25, 2017 at 12:00 PM",
         "formattedAxisTime":"Nov 25 at 12:00 PM",
         "value":[44],
         "formattedValue":["44"]
       },
       {
         "time":"1511632800",
         "formattedTime":"Nov 25, 2017 at 1:00 PM",
         "formattedAxisTime":"Nov 25 at 1:00 PM",
         "value":[41],
         "formattedValue":["41"]
       }
     }]
   }
}
 
    