21 ms·
You can take the part before `.then()` and pass it around.
by egeozcan 10y ago
You can take the part before `.then()` and pass it around.
- woudsma 10y agoyes 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) }