I'm running a project on expo, but i'm having difficulties implementing the firestore backend into the code. Not that much helpful documentation out there to help with the syntax.
I've created a separate file named usersApi:
import firebase from "firebase"
require("firebase/firestore");
import React, { Component } from 'react';
const firebaseConfig = {
apiKey: "...",
authDomain: "...",
databaseURL: "...",
projectId: "...",
storageBucket: "...",
messagingSenderId: "...",
appId: "..."
};
!firebase.apps.length ? firebase.initializeApp(firebaseConfig) : firebase.app();
export function addUsers(child, addComplete){
firebase.firestore().collection('users').add({
fname: child.name,
lname: child.name,
createdAt: firebase.firestore.FieldValue.serverTimestamp()
}).then((data) => addComplete(data))
.catch((error) => console.log(error));
}
export function getNames(namesRetrieved){
My desired goal is to retrieve the names the user enters into the app on a form sheet and store it in the firestore database. This is in the attendance.js file:
export default class Attendance extends Component {
state = {
childFistName: '',
childLastName: '',
tableHead: ['First Name', 'Last Name', 'Time in', 'Time out'],
students: []
}