i want to update the data without refreshing the page when there are changes in firestore

The error you are getting is very descriptive and specific. res.write() only takes certain argument types and you’re not giving it one of the permitted types. You’re passing it an object which is not permitted.

This is because doc.data() returns an object. If you want the send the object as your response, then you can change things to send it as JSON like this:

app.get('/', (req, res) => {
    res.writeHead(200, {
        'Content-Type': 'application/json',        // set JSON content-type
        'Cache-Control': 'no-cache',
        'Connection': 'keep-alive',
    });
    const doc = db.collection('TestingData').doc('uQZu5OA0XZZQtG0fKSVG');
    const observer = doc.onSnapshot(doc => res.write(JSON.stringify(doc.data())));
});

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top