I have tried to move things around but my call to my database in cloud firestore is returning a nil for some reason. I have data in the database, and triple checked the relation but can't seem to find why it's acting the way it is.
Here is my code for the function:
func getAllTasks() -> [String: Any] {
db = Firestore.firestore()
var customers : [String: Any]!
db.collection("CustomerCollection").whereField("uploaded", isEqualTo: true)
.getDocuments() { (querySnapshot, err) in
if let err = err {
print("Error getting documents: \(err)")
} else {
for document in querySnapshot!.documents {
print("\(document.documentID) => \(document.data())")
customers = document.data()
}
}
}
return customers
}
When this is called the error is at the .getDocuments part, it is underlined and the error states: "Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"
Here is my database as well