Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want users to be able to join a
specific group by clicking on a "Join Group" button located at the particular group's screen. I've created a member model in firestore where I wrote the below code but it does'nt work.

What I have tried:

//Adding a member model

export function addMember (addComplete, member) {
const user = firebase.auth().currentUser;
let member_id = firebase.auth().currentUser.uid
const {currentUser} = firebase.auth()

firebase.firestore()
.collection('members')
.add({
member: member_id,
email: currentUser.email,
createdAt: firebase.firestore.Timestamp.fromDate(new Date()),
}).then((snapshot) => snapshot.get()
).then((memberData) => addComplete(memberData.data()))
.catch((error) =>console.log(error));

}

Basically, anytime I clicked on the "Join Group" button, the current user is being added to all the groups instead of a single group.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900