簡體   English   中英

如何從節點 js 應用程序向客戶端發送實時更新

[英]how to send realtime updates to client from node js app

I am using firebase realtime database and firebase firestore in my web app and everytime a user updates their data firebase is sending that data to my server and I want to send that data to client how do it do it because with my current code it is giving我 res.setHeader 錯誤

您正在尋找的是使用onSnapshot的實時更新。

這里是相關教程https://firebase.google.com/docs/firestore/query-data/listen

NodeJS 的示例是:

const doc = db.collection('cities').doc('SF');

const observer = doc.onSnapshot(docSnapshot => {
  console.log(`Received doc snapshot: ${docSnapshot}`);
  // ...
}, err => {
  console.log(`Encountered error: ${err}`);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM