I am receiving a TypeError: n.indexOf is not a function error when trying to access the customers collection in my database. However, I can access the products collection fine.
This is the code I’m trying:
const taskQuery = doc(collection(db, "customers"), where("uid", "==", user.uid))
const loadCheckout = async (priceId) => {
try {
const taskDocs = await getDocs(taskQuery)
} catch (error) {
console.log(error.message)
}
}
user.uid is defined and because I can access the ‘products’ collections, the app initialisation is hooked up correctly. If I remove the ‘where(“uid”…)’ I get a ‘Missing or insufficient permissions’ error which lead me to believe there is something wrong in the rules.
Rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /customers/{uid} {
allow read: if request.auth.uid == uid;
match /checkout_sessions/{id} {
allow read, write: if request.auth.uid == uid;
}
match /subscriptions/{id} {
allow read: if request.auth.uid == uid;
}
match /products/{id} {
allow read: if true;
match /prices/{id} {
allow read: if true;
}
match /tax_rates/{id} {
allow read: if true;
}
}
}
}