Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added code to handle invalid ga login and pass the error back to the …

…callback function
  • Loading branch information...
commit 707693fca3c8d0e8e3e34eb1b09a66e2ec748317 1 parent 5e2b4af
@jamescharlesworth jamescharlesworth authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/ga.js
View
9 lib/ga.js
@@ -49,6 +49,11 @@ GA.prototype.login = function(cb) {
var self = this;
this.on('token', this.captureToken);
+ //handle invalid login errors
+ this.on('error', function(err){
+ cb(err, null);
+ });
+
if (cb) this.on('token', cb);
var postData = {
@@ -122,7 +127,7 @@ GA.prototype.get = function(options, cb) {
,dimension_index;
var data_data = combineChunks(chunks, length).toString();
-
+
var parsed_data = JSON.parse(data_data);
for (var col=0; col<parsed_data.columnHeaders.length; col++){
@@ -154,7 +159,7 @@ GA.prototype.get = function(options, cb) {
}
if (typeof cb === 'function' ) cb(null, entries);
-
+
});
});
req.end();
Please sign in to comment.
Something went wrong with that request. Please try again.