However, promisey code is still hard to read, because promises are basically a bolt-on replacement for language primitives like try, catch, and return:
var db = new PouchDB('mydb');
db.post({}).then(function (result) { // post a new doc
return db.get(result.id); // fetch the doc
}).then(function (doc) {
console.log(doc); // log the doc
}).catch(function (err) {
console.log(err); // log any errors
});
What if I told you that, with ES7, you could rewrite the above code to look like this:
let db = new PouchDB('mydb');
try {
let result = await db.post({});
let doc = await db.get(result.id);
console.log(doc);
} catch (err) {
console.log(err);
}