Alvin
Alvin

Reputation: 408

PouchDB on Cloudant

I am currently using PouchDB and I am making use of Cloudant to make my db in PouchDB to be on cloud.

I did callback method and it gave a success callback, however, I check my database on Cloudant, there's 0 doc created but there's 8 update seq.

May I know why? This is my set of code I used.

function pouchdb() {

    var db = new PouchDB("todos");
    var remoteDB = new PouchDB("http://example.cloudant.com/example");

    var todo = {
        _id: "mittens1233",
        title: "hello",
        occupation: "kitten123"
    };

    db.put(todo, function callback(err, result) {
        if (!err)
            console.log('Successfully posted a todo!');
    });

    db.put(doc);
    PouchDB.sync(db, remoteDB);

}

The result i got back is

Successfully posted a todo!

Upvotes: 1

Views: 472

Answers (1)

Alvin
Alvin

Reputation: 408

Solution:

My error was because the host link I was using was incorrect. It should be in a format of http://username:[email protected] . I generated an API key and used the key as username and password as password. Then it worked. I was able to create and query document.

Upvotes: 1

Related Questions