You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/02/11 10:35:56 UTC

[GitHub] sarics commented on issue #66: Is a native promise version planned

sarics commented on issue #66: Is a native promise version planned
URL: https://github.com/apache/couchdb-nano/issues/66#issuecomment-364741177
 
 
   I had the same problem, so I looked around in the code, and found that there is a `request` config option, so you can use other request-like module, [request-promise-native](https://www.npmjs.com/package/request-promise-native) for example.
   And, for every function, nano simply returns the request call.
   
   So, if you combine the two, you have a promisified nano ?:
   ```javascript
   const nano = require('nano');
   const request = require('request-promise-native');
   
   const couch = nano({
     url: 'http://localhost:5984',
     // requestDefaults can't be used here, pass request.defaults({...}) to request instead
     request: request.defaults({
       resolveWithFullResponse: true, // set to false if you only need the response body
       json: true,
     }),
   });
   
   couch.use('_users').info()
     .then(({ headers, body }) => {
       console.log(headers, body);
     });
   ```

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services