只要避免
Promise构造函数反模式-promise-construction-antipattern-and-how-to-avoid-
it)!如果您不调用
resolve而是返回一个值,那么您将需要进行一些操作
return。该
then方法应该用于链接:
outer.get('/account', function(req, res) { var id = req.user.uid var userRef = firebase.db.collection('users').doc(id) var profilePromise = userRef.get().then(doc => { if (doc.exists) { var profile = doc.data() profile.id = doc.id return profile // I assume you don't want to return undefined// ^^^^^^ } else { throw new Error("Profile doesn't exist")// ^^^^^ } }) // More promises further on, which I wait for: // profilePromise.then(myProfile => { … });})


