percolatestudio / meteor-google-api

A simple API encapsulating some common patterns regarding Google's APIs
https://atmospherejs.com/percolate/google-api
MIT License
48 stars 30 forks source link

result.data set to null when retrieving contacts using contacts API #22

Closed phsultan closed 9 years ago

phsultan commented 9 years ago

Hi,

I'm trying to retrieve my contacts list

var options = {};
GoogleApi.get('m8/feeds/contacts/default/full', options, function(error, result){
          if (error) {
            console.log('error from callback : ' + error);
          } else {
            console.log('result from callback : ' + JSON.stringify(result));
          }

I'm not getting any error but result is set to null.

However, the following code works (adding 'alt':'json' as a parameter) :

var options = { 'params': {'alt': 'json'}};
GoogleApi.get('m8/feeds/contacts/default/full', options, function(error, result){
          if (error) {
            console.log('error from callback : ' + error);
          } else {
            console.log('result from callback : ' + JSON.stringify(result));
          }

Digging into this, I figured out that Google would send its reply with result.data set to null without this workaround, and the package passes the result.data to the callback after evaluating result (from google-api-async.js):

      HTTP.call(method, this._host + '/' + path, options, function(error, result) {
        callback(error, result && result.data);
      });

I don't know if I did make the right API call though, any advice is welcome.

Thanks !

tmeasday commented 9 years ago

Hi @phsultan -- yes see this associated comment: https://github.com/percolatestudio/meteor-google-api/issues/21#issuecomment-124264237

I see a few people are running into this. I guess we might need to consider a version 2.0 of this library that more closely reflects the HTTP library it wraps.

phsultan commented 9 years ago

Yes, I'm closing this issue as there is an easy workaround anyway (adding atl=jsonto the request parameters).

Thanks !