title: Return array from firestore
body: <p>new to swiftui and firestore and struggling with calling this document array. Hoping someone can help me out with the code to call the &quot;items&quot; array into a VStack.</p>
  <p><a href="https://i.stack.imgur.com/adYKt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/adYKt.png" alt="enter image description here" /></a></p>
  <p>Added code I've been trying</p>
  <p>View Model</p>
  <pre><code>import SwiftUI
  import FirebaseFirestore
  
  class MovieItemViewModel: ObservableObject {
      
      @Published var movieItems = [MovieItem]()
      
      private var db = Firestore.firestore()
      
      func fetchData() {
          db.collection(&quot;movies&quot;).order(by: &quot;items&quot;).addSnapshotListener { (querySnapshot, error) in
              guard let documents = querySnapshot?.documents else {
                  print(&quot;No Documents&quot;)
                  return
              }
              
                  self.movieItems = documents.map { (queryDocumentSnapshot) -&gt; MovieItem in
                  let data = queryDocumentSnapshot.data()
                  
                  let items = data[&quot;items&quot;] as? String ?? &quot;&quot;
                      
                  return MovieItem(item: items)
                  
              }
              
          }
      }
  }
  </code></pre>
  <p>Model</p>
  <pre><code>import SwiftUI
  
  struct MovieItem: Identifiable {
      var id: String = UUID().uuidString
      var item: String
  }
  </code></pre>
  <p>Main View</p>
  <pre><code>struct MovieDetailListView: View {
      
      @ObservedObject private var viewModel = MovieItemViewModel()
  
      var body: some View {
  
       VStack(alignment: .leading, spacing: 15){
          ForEach(viewModel.movieItems.indices, id: \.self) { i in
          Text(viewModel.movieItems[i].item) 
          } 
       }
       .onAppear() { self.viewModel.fetchData() }
  }
  }
  
  </code></pre>