pouchdb-auth icon indicating copy to clipboard operation
pouchdb-auth copied to clipboard

TypeError: Promise.resolve is not a function on pouchdb-auth

Open semiautomatix opened this issue 6 years ago • 1 comments

Issue

I'm receiving the following error when using pouchdb-auth:

TypeError: Promise.resolve is not a function

PouchDB../node_modules/pouchdb-auth/lib/index.js.exports.useAsAuthenticationDB
/PWAProjects/pwa-tna/node_modules/pouchdb-auth/lib/index.js:63

  60 | }
  61 | 
  62 | 
> 63 | return utils.nodify(Promise.resolve().then(function () {
  64 |   // add wrappers and make system db
  65 |   if (!info.isOnlineAuthDB) {
  66 |     wrappers.installWrapperMethods(args.db, writeWrappers);

Info

  • Environment: React.js
  • Platform: Chrome
  • Adapter: n/a
  • Server: CouchDB

Reproduce

My code is as below:

import PouchDB from 'pouchdb';
import pouchDBAuth from 'pouchdb-auth'; 
PouchDB.plugin(pouchDBAuth);

const db = new PouchDB(
    'http://localhost:5984/accord-tna',
    {
        skip_setup: true,
        auth: {
            username: 'admin',
            password: 'password',
        }
    }
  );
db.useAsAuthenticationDB();

As quick check does indeed reveal Promise.resolve to be undefined using the pouchdb-promise import.

semiautomatix avatar Jan 28 '19 10:01 semiautomatix

+1

Hello, @marten-de-vries

The problem is here:

# lib/index.js
var Promise = require('pouchdb-promise');

We are getting { default: Promise };

Please replace it to require('pouchdb-promise').default;

OR update version to 7.0.0 in package.json: "pouchdb-promise": "^6.4.1",

95kach avatar Apr 16 '19 05:04 95kach