smcgee31 opened a new issue #118: Using promises only returns body
URL: https://github.com/apache/couchdb-nano/issues/118
 
 
   When I try to run code in a promises type of way, either raw promises or 
async/await the returned information is only `{ body }`, not `{ err, body, 
header }`. However, when I write the code as callbacks I do get `{ err, body, 
header }` as expected.
   
   ## Expected Behavior
   My understanding is that when I write my code like...
   ```js
   async function saveData(submission) {
     try {
       const result = await myDb.insert(submission);
       return result;
     } catch (error) {
       throw new DatabaseError(error);
     }
   }
   ```
    I should get an object back like...
   ```json
   {
     "err": null,
     "body": {
       "ok": true,
       "id": "14ac5e3dc6f74c19d7f3a0f28946a997",
       "rev": "1-6679afee204060e7893f58ced4ffe89c"
     },
     "header": {
       "uri": "localhost:5984/myDb",
       "statusCode": 201,
       "location": "localhost:5984/myDb/14ac5e3dc6f74c19d7f3a0f28946a997",
       "etag": "\"1-6679afee204060e7893f58ced4ffe89c\"",
       "date": "Sat, 25 Aug 2018 15:55:47 GMT",
       "content-type": "application/json",
       "cache-control": "must-revalidate"
     }
   }
   ```
   
   ## Current Behavior
   When using promises the returned object is only `body` ...
   ```json
   {
     "ok": true,
     "id": "0ad5b89865ced95aa88142ea1d9c2462",
     "rev": "1-6679afee205010e7893f58ced4cfe79c"
   }
   ```
   
   ## Possible Solution
   It seems that the information is probably there, just not being included in 
the return somehow.
   (I was going to attempt a PR but when I fork, clone, `npm i`, and run tests 
I get failing tests and haven't been able to figure out why)
   
   ## Your Environment
   * Version used: Apache CouchDB 1.6.1
   * Browser Name and version: Google Chrome Version 68.0.3440.106 (Official 
Build) (64-bit)
   * Operating System and version (desktop or mobile): macOS High Sierra 
version 10.13.6 
   

----------------------------------------------------------------
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

Reply via email to