glynnbird commented on a change in pull request #102: Promise support for Nano
- Issue 98
URL: https://github.com/apache/couchdb-nano/pull/102#discussion_r203361001
##########
File path: lib/nano.js
##########
@@ -471,12 +514,27 @@ module.exports = exports = nano = function dbScope(cfg) {
//
http://docs.couchdb.org/en/latest/api/document/common.html#head--db-docid
function headDoc(docName, callback) {
- return relax({
- db: dbName,
- doc: docName,
- method: 'HEAD',
- qs: {}
- }, callback);
+ // this function doesn't pass on the Promise from relax because it needs
+ // to return the headers when resolving the Promise
+ return new Promise(function(resolve, reject) {
+ relax({
+ db: dbName,
+ doc: docName,
+ method: 'HEAD',
+ qs: {}
+ }, function(err, body, headers) {
+ if (err) {
+ if (callback) {
+ callback(err);
Review comment:
Good point 👍
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services