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

Invalid plugin: got "undefined", expected an object or a function #227

Open
lakinmohapatra opened this issue Mar 10, 2018 · 9 comments
Open

Comments

@lakinmohapatra
Copy link

getting error on this
PouchDB.plugin(PouchAuth);

rror: Invalid plugin: got "undefined", expected an object or a function
Error: Invalid plugin: got "undefined", expected an object or a function

@broerse
Copy link
Collaborator

broerse commented Mar 10, 2018

Do you do something like this?

var PouchDB = require("pouchdb");
var PouchAuth = require("pouchdb-authentication");
PouchDB.plugin(PouchAuth);

@lakinmohapatra
Copy link
Author

yes

@ptitjes
Copy link
Collaborator

ptitjes commented Mar 11, 2018

Hi @lakinmohapatra, thanks for you report.

You have to give us more information for us to help you, as we are not mind readers yet. The issue template, that you promptly deleted, asked you some questions for exactly this reason. So as of your issue, we need at least to know:

  • what language, packaging and execution environment do you use,
  • the exact code you use to import/require PouchDB and PouchDB Authentication and the exact code you use to initialize those.

@lakinmohapatra
Copy link
Author

import { Injectable } from '@angular/core';
import PouchDB from 'pouchdb';
import PouchAuth from 'pouchdb-authentication';

@Injectable()
export class CouchAuthenticateService {
db : any;

constructor() {
PouchDB.plugin(PouchAuth);
this.db = new PouchDB('http://127.0.0.1:5984/tata');
}

signup(formData : any) {
console.log(formData);
return this.db.signup(formData.userName, formData.password, {
metadata : {
email : formData.email,
}
});
}

signin(formData : any) {
console.log(formData);
return this.db.login(formData.userName, formData.password);

}

}

@lakinmohapatra
Copy link
Author

"pouchdb-authentication": "^0.5.5",

@lakinmohapatra
Copy link
Author

lakinmohapatra commented Mar 14, 2018

I have updated it to 1.12 . But still showing error.

import PouchDB from 'pouchdb';
import * as PouchAuth from 'pouchdb-authentication';

Showing this.db.login is not a function.

Using angular 5

@ptitjes
Copy link
Collaborator

ptitjes commented Mar 14, 2018

@lakinmohapatra So it seems to be Typescript code. Can you show your tsconfig.json please ?

Side note: the PouchDB.plugin(PouchAuth) should be in the header just after the imports.

@ptitjes
Copy link
Collaborator

ptitjes commented Apr 6, 2018

@lakinmohapatra any news ?

@lakinmohapatra
Copy link
Author

I will share tsconfig. Thanks for the reminder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants