'Uncaught (in promise) TypeError: _firebase__WEBPACK_IMPORTED_MODULE_7__.db.collection is not a function
I want to add usersOrderInfo collection inside users document.I tried this way:
db
.collection('shopDB')
.doc(user.uid)
.collection("userOrderInfo")
.doc(paymentInfo.id)
.set({
orders:basket,created:paymentIntent.created},{merge:true})
But this throw an error :
Uncaught (in promise) TypeError: _firebase__WEBPACK_IMPORTED_MODULE_7__.db.collection is not a function
I am using firebase version 10.5.0
Solution 1:[1]
The set() takes data of document as parameter. Try refactoring the code as shown below:
db
.collection('shopDB')
.doc(user.uid)
.collection("userOrderInfo")
.doc(paymentInfo.id)
.set(DOC_DATA)
Also do ensure that no field is undefined.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharmaraj |
