Как передать данные Dynami c из формы в Firestore с помощью Cordova? - PullRequest
0 голосов
/ 05 августа 2020

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 Ответ

1 голос
/ 06 августа 2020

Значение переменной не определено. Это должно решить эту проблему.

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(),
})
...