How to fetch user data?

firestore contents I am trying to fetch my user data from firestore I set up a model class that’s an observable object to fetch the document data from Firestore to appear on the user interface but I been receiving this error. How do I fix this code to get user data from Firebase ?

Cannot convert value of type 'String' to expected argument type 'URL'

class NewUserData: ObservableObject {
    
    @Published var datas = [UserModelFile]()
    
   
    
    func fetchUser() {
        let db = Firestore.firestore()
      let ref = db.collection("user")
            
        ref.getDocuments { snapshot, error in
            guard error == nil else {
                print(error!.localizedDescription)
                return
            }
        
            if let snapshot = snapshot {
                for document in snapshot.documents {
                    let data = document.data()
                    
                    let username = data["username"] as? String ?? ""
                    let bio = data["bio"] as? String ?? ""
                    let profileImages = data["bio"] as? String ?? ""
                    
                    let data = UserModelFile(username: username, bio: bio
                                             , ProfileImages: profileImages)
                    self.datas.append(data)
                }
 


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation