第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Google Firestore 的承諾

Google Firestore 的承諾

慕田峪4524236 2021-09-30 16:41:11
我目前正在嘗試研究如何使用 Firestore 和 NodeJS 進行基本查詢。我收到錯誤“預(yù)期的捕獲()或返回”。我希望有人能解釋為什么會這樣?我正在使用快速路由器來處理路由。方法 1. ESLint 錯誤userRouter.get("randomroutename", (req, res) => {    const uid = req.params.uid;    console.log("User: " + uid);    let collectionRef = db.collection('col');    collectionRef.add({foo: 'bar'}).then(documentReference => {        console.log(`Added document with name: ${documentReference.id}`);        res.status(200).send('SUCCESS');    });});在環(huán)顧四周并嘗試了一些事情之后,這似乎可行,但是我真的很困惑為什么需要回報。當(dāng)函數(shù) 'add' 肯定返回我可以訪問 .then 的承諾時,為什么我需要返回承諾對我來說真的沒有意義。方法2.沒有錯誤userRouter.get("randomroutename", (req, res) => {    const uid = req.params.uid;    console.log("User: " + uid);    let collectionRef = db.collection('col');    return collectionRef.add({foo: 'bar'}).then(documentReference => {        console.log(`Added document with name: ${documentReference.id}`);        return res.status(200).send('SUCCESS');    });});根據(jù)文檔(https://googleapis.dev/nodejs/firestore/latest/CollectionReference.html),我相信方法 1 應(yīng)該有效。謝謝你的幫助?。ǚ浅1福绻@太明顯了,我就是無法理解它......)
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 191 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號