Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose internal request object #106

Closed
omriiluz opened this issue Nov 27, 2013 · 4 comments
Closed

expose internal request object #106

omriiluz opened this issue Nov 27, 2013 · 4 comments
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged.

Comments

@omriiluz
Copy link

Need to keep track and/or expose the internal request object so application can customize behavior - for example track progress of upload/download.

the ideal option is to use eventEmitter like the original Request module is doing and raise an event with the reququest object once it's submitted..

another option is to return a request object wrapper in the execute method which is currently not returning anything.

and yet another (simple) option is to keep the last request created in a variable under the DefaultTransporter object.
I am currently using this option but I'm not making a pull request as I don't think it's elegant/generic enough.

DefaultTransporter.prototype.request = function(opts, opt_callback) {
  opts = this.configure(opts);
  this.innerRequest = request(opts, this.wrapCallback_(opt_callback));
};
@omriiluz
Copy link
Author

omriiluz commented Dec 6, 2013

After using the simple implementation described above for a few weeks in a heavily used app it seems to be working fine and very stable. I created pull request #111 for the change.

@ryanseys
Copy link
Contributor

Fixed in 1.0.0. We have exposed the request object with every API call. It is the return value for every API call.

Example in 1.0.0:

var google = require('googleapis');
var drive = google.drive('v2');

var req = drive.files.insert({ /* ... */, callback);
// access upload / download progress here
console.log(req.uri.href); // example that prints out api endpoint being requested

@omriiluz
Copy link
Author

Thanks, it's working great. I've migrated to 1.0 and adapted to the changes, my app is working perfectly right off your release code without any "hacks" anymore.

@ryanseys
Copy link
Contributor

Happy to hear! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants