Search code examples
javascriptnode.jsgoogle-analyticsgoogle-analytics-api

Google Analytics API on node js goes into a wait without ever giving results


Hello I'm developing a web app and in my back-end i have a restful route that must ask google analytics for some data to send to the app. The problem that i encounter is that when i start the server, the first 5/6 api requests it goes all well witouth problems, but after that our route stops working going in a infinite wait situation. Our code is like this:

const { google } = require('googleapis');
const scopes = 'https://www.googleapis.com/auth/analytics.readonly'
const jwt = new google.auth.JWT(key.client_email, null, key.private_key, scopes)

async getData(){  //This is our route function
    const res = await jwt.authorize()
    let result = await google.analytics('v3').data.ga.get({'...'});
}

With the help of some old fashioned console.log we found that our program stops on the data.ga.get function, we have tried to follow some tutorials in search for an answer but didn't have luck, can anyone help?


Solution

  • I don't have a technical and thorough answer to your question, however in my experience using GoogleAPIs I have commonly found end-points temporarily blocked if too many requests are sent within a small window of time.

    Apologies for not having a more rigorous suggestion. If you have not already done so, I would consider this possibility.