user4840960
user4840960

Reputation:

PouchDB is not defined

I am trying to instantiate PouchDB in a javascript file. I am importing it with below code :

var imported = document.createElement('script');
imported.type = 'text/javascript';
imported.src = 'pouchdb-6.1.2.js';
document.head.appendChild(imported);

Inside my custom function I am instantiating it as :

var db = new PouchDB('mydb');

This, however, is throwing an error - 'Uncaught ReferenceError: PouchDB is not defined'. Please Help

Upvotes: 0

Views: 2397

Answers (2)

cgeiser
cgeiser

Reputation: 31

Download the latest PouchDb minified here: https://github.com/pouchdb/pouchdb/releases/download/6.2.0/pouchdb-6.2.0.min.js

Put it in your js or scripts folder and the list it in your index.html file:

<script type="text/javascript" src="js/pouchdb-6.2.0.min.js"></script>

Upvotes: 0

Megidd
Megidd

Reputation: 7938

Did you try this to see if it works:

imported.src='//cdn.jsdelivr.net/pouchdb/6.2.0/pouchdb.min.js'

Also, you can try to add the script tag inside HTML:

<head>
    <script src="//cdn.jsdelivr.net/pouchdb/6.2.0/pouchdb.min.js"></script>
</head>

Upvotes: 1

Related Questions