How to pass dynamic data from form into Firestore using Cordova?

189 views Asked by At

Example taken from Firebase Guide

I have a form and I want to pass the form input values into here. How do I populate "San Francisco" dynamically based on what the form input values are?

I have tried creating variables and populate the fields with the variables as such but I received an error message that says

error.ts:166 Uncaught FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined (found in field eventName in document events/RNiEJ9nUxVO1IGFr0TL5)

enter image description here

Reference link: https://firebase.google.com/docs/firestore/query-data/get-data#web

1

There are 1 answers

0
Donavan Er On

The variable value was undefined. This should solve it.

db.collection("events").add({
    eventName: document.getElementById('eName').value.toString(),
    organiserName: document.getElementById('oName').value.toString(),
    eventDescription: document.getElementById('oDesc').value.toString(),
    eDateTime: document.getElementById('eDateTime').value.toString(),
    eType: document.getElementById('eType').value.toString(),
})