3 ms·
yes that works quite great. you have to define a 'async' function, in which you can use the 'await' keyword. async getDoc(doc) { const result = await db.get
by woudsma 10y ago
yes that works quite great.
you have to define a 'async' function, in which you can use the 'await' keyword.
async getDoc(doc) {
const result = await db.get(doc)
console.log('result:', result)
}
// instead of:
function getDoc(doc) {
db.get(doc, result => {
console.log('result:', result)
});
}
// or
function getDoc(doc) {
db.get(doc)
.then(result => 'result: ' + result)
.then(::console.log)
.catch(::console.error)
}