Below code calls the Google Analytics Reporting API using Google's nodejs client version 0.7
here. It returns a socket hang up
error on some executions but not always. Would this be errors on Google's servers' end? Is there an easy way to debug? BTW I'm making several calls consecutively, not sure if it's caused by rate limits.
gapi = require "googleapis"
authClient = new gapi.auth.JWT(
config.ga.clientEmail,
config.ga.privateKeyPath,
null,
[config.ga.scopeUri]
)
authPromise = new Promise (resolve, reject) ->
authClient.authorize (err, token) ->
resolve token
return
return
authPromise.then ->
gapi.discover('analytics', 'v3')
.withAuthClient(authClient)
.execute (err, client) ->
...