I find myself making a chat using Firebase and JS.
In the last function I added, I would have to store the messages sent to the database (If I understand correctly the tutorial you guided me through). When doing so, I get the following errors:
The function is the following:
const contenidoChat = (user) = () => {
formulario.addEventListener('submit', event => {
event.preventDefault()
console.log(contenidoChat.value)
if(!inputChat.value.trim()){
console.log('texto vacio')
return
}
firebase.firestore().collection('chat').add({
texto: inputChat.value,
uid: user.uid,
fecha: Date.now()
}).then(res => {console.log('texto agregado')})
.catch( e=> console.log(e))
})
}
There are 2 possible things that generate the error
1.-
change
By
2.- Possibly you are not sending the user variable correctly