简体   繁体   中英

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

取自 Firebase 指南的示例

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)

在此处输入图像描述

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM