Currently in the process of developing an e-commerce platform using Vue and Firebase. I am encountering an issue when attempting to add cart information for the logged-in user. Surprisingly, the information is saved perfectly on the initial attempt. However, subsequent attempts fail with the following error:
Uncaught FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined
To resolve this issue, I have to refresh the page before it works again. The source of the problem eludes me.
It's worth mentioning that if I try adding any other value besides the cart, it functions correctly.
checkoutLoggedInUser(){
var db = firebase.firestore();
var user = firebase.auth().currentUser;
db.collection("orders").add({
user_id:user.uid,
cart:this.$store.getters.cart
})
this.$store.commit('emptyCart')
this.$router.push({ name: 'Home'})
}