Answers for "firebase get last document"

0

firebase get last document

//using React
//Make sure to import and initialize your Firebase App
const firestore = firebase.firestore();
const collection = firestore.collection("myCollection");
const { documentData, setDocumentData } = useState({});

const getDocument = () => {
  collection.get()
  .then((snapshot) => {
    setDocumentData(snapshot[0].data());
  });
}

useEffect(() => {
	getDocument();
}, []);
Posted by: Guest on April-13-2022

Code answers related to "firebase get last document"

Code answers related to "Javascript"

Browse Popular Code Answers by Language