Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: Cannot read property 'FieldValue' of undefined

  19 | event.preventDefault();
  20 | db.collection('todos').add({
  21 |   todo:input,
  22 |   timestamp: firebase.firestore.FieldValue.serverTimestamp()
  23 |  });
  24 | 
  25 | setInput("");

Whenever I try to run this code, it shows me type error. So that I cant able to push the data to firebase

like image 445
sangeeth kumar Avatar asked Dec 04 '25 04:12

sangeeth kumar


1 Answers

For those who are using the Admin SDK with NodeJS:

import { FieldValue } from '@google-cloud/firestore'

const docData = {
  userName: 'Lucas'
  createdAt: FieldValue.serverTimestamp()
}

You could find all the external API's references here: https://firebase.google.com/docs/reference/admin/node/firebase-admin.firestore

like image 149
Lucas David Ferrero Avatar answered Dec 06 '25 18:12

Lucas David Ferrero