Fir*_*nks 0 javascript unreachable-code firebase angular google-cloud-firestore
我在打字稿文件中收到警告“检测到无法访问的代码”。运行 Firebase 事务后没有任何效果。这是交易代码:
// Create Firestore reference
let pointsRef = 'Users/'+this.user.uid;
var pointsDocRef = this.afs.doc(pointsRef).ref;
return this.afs.firestore.runTransaction((transaction) => {
return transaction.get(pointsDocRef).then((ptsDoc) => {
if(!ptsDoc.exists){
throw "Document does not exist!"
}
var newPtsScore = ptsDoc.data().points - 20;
transaction.update(pointsDocRef, { points: newPtsScore });
});
}).then(() => {
console.log('Point count successfully decremented for new item');
// Close dialog
this.dialog.closeAll();
}).catch(function(error) {console.log('Transaction failed: ', error);});
console.log('Hey there!'); <-- "UNREACHABLE CODE DETECTED"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1085 次 |
| 最近记录: |