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

No callback response on success? #21

Closed petr24 closed 9 years ago

petr24 commented 9 years ago

Hey I am using the google api, when I try to delete a users contact, it works succesfully, but in the success response, it returns null. I event made it err out on purpose to see if errors show up and they do, but for some reason on delete I get nothing in the success block. Am I doing something wrong? My code is below. On other calls such as retrieving a users contacts, all works as expected.

var url = "/m8/feeds/contacts/default/full/"+contactData.cId+"?v=3.0";

GoogleApi.delete(url, { 'headers': {"Content-Type": "application/atom+xml", "If-Match": contactData.eTag}}, function (err, data) { if (err) { console.log('err del ', err); }else { //returns null here. console.log('del works ', data); } });

Here is the response in my dev console. "del works null"

phsultan commented 9 years ago

Hi @petr24,

According to this URL https://developers.google.com/google-apps/contacts/v3/#deleting_contacts, it looks like this method is not supposed to return any data. So if you don't hit the 'if (err) {}' block, I'd say your action has been successfully processed.

Cheers,

petr24 commented 9 years ago

Hey @phsultan,

In the docs it says "Upon success, the server responds with an HTTP 200 OK status code.", but as you mentioned if it doesn't hit the 'if (err) {}' block I am in the clear, so i'll leave it that. For curiosity however, I also tried this with the Meteor HTTP package and that does return a response on success, I am almost thinking this package hides it maybe?

Thanks.

phsultan commented 9 years ago

True, and this package uses Meteor.HTTP :

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

@tmeasday, would it be acceptable to include the HTTP response code in the object passed to the callback ?

If so, this would do it (adding a statusCodefield to the object passed to the callback):

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

Don't know if that would be the right way to do it though.

tmeasday commented 9 years ago

I think the right thing to do would be to pass the whole result back rather than just the data. I'm not sure why we decided to do it that way in the first place.

Problem is of course it'd be a big breaking change to do that. Hmmm..