Created
May 16, 2016 08:25
-
-
Save ronycohen/76c67e56df38d80dd067af93915df3c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var PouchDB = require('pouchdb'); | |
PouchDB.plugin(require('pouchdb-authentication')); | |
//with Admin account | |
var dbUrl = encodeURI('https://mylogin:[email protected]/testaccess'); | |
var db = new PouchDB(dbUrl, {skipSetup: true}); | |
var options = { | |
metadata : { | |
email : '[email protected]', | |
birthday : '1932-03-27T00:00:00.000Z', | |
likes : ['acrobatics', 'short pants', 'sidekickin\''], | |
} | |
}; | |
console.log("go signup"); | |
db.signup('batman', 'brucewayne', options) | |
.then(function(response){ | |
console.log(response); | |
return response; | |
}) | |
.then(function(response){ | |
console.log("response",response); | |
return db.login('superman', 'clarkkent'); | |
}) | |
.then(function(login){ | |
console.log("login",login); | |
}) | |
.catch(function(err){ | |
console.log(err); | |
if (err.name === 'conflict') { | |
console.log("batmanalready exists, choose another username"); | |
} else if (err.name === 'forbidden') { | |
console.log("invalid username"); | |
} else { | |
console.log(err,"HTTP error, cosmic rays, etc."); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment