ELing
ELing

Reputation: 259

PouchDB and Vue.js integration

Did anyone of you integrate PouchDB / vue-pouch-db within your Vue.js app? I got an error when defining PouchDB database.

I had used below definitions:

import PouchDB from 'pouchDB'
or
import PouchDB from 'vue-pouch-db'
or
const PouchDB = require('vue-pouch-db')

const db = new PouchDB('database_name')
or
const db = PouchDB('database_name')

None of them works for me.

Errors:

What is the proper way to initialize PouchDB in Vue ?? Thanks a lot !

Upvotes: 0

Views: 3124

Answers (2)

Balaji
Balaji

Reputation: 11017

just add default, if you get this constructor is not a function

const PouchDB = require('pouchdb').default;

i am using vue with pouchdb ,it works great because i am getting same problem like you

Upvotes: 0

trojek
trojek

Reputation: 3228

In order to initialize PouchDB in Vue.js (2) you should:

import PouchDB from 'pouchdb-browser'
let localDB = new PouchDB('mylocaldb');

Of course, before using the certain package you must install it, e.g. via npm: npm install pouchdb-browser

Upvotes: 1

Related Questions