I am trying to push an object into an array that is stored to the user in firebase. I have this. It starts on click
function savetodb() {
auth.onAuthStateChanged(user => {
if(user) {
db.collection('users').doc(user.uid).get().then(doc => {
const saveditems1 = doc.data().saveditems
saveditems1.push({
Name:'Test',
Price:'Test',
Link:'https://www.test.com'
})
});
}
else {
return alert('no')
}
})
There is no errors in the console, but it doesn't add anything to the user's array.
Here is the on click function
<button id="savedb" onclick='savetodb()'>Save For Later</button>
I don't know why It isn't adding to the array. Here is how it is stored in firestore
