title: How to display a Rest API call in swiftUI?
body: <p>I am following a tutorial for a simple Rest API call for a swiftui app, but when trying to ping another api I am unable to decode and show the response.</p>
  <p>The only things changed from the tutorial are the API call and changing the model id as the api doesn't return an id.</p>
  <pre><code>import SwiftUI
  
  struct ContentView: View {
      
      @State var results = [TaskEntry]()
    
      var body: some View {
          List(results, id: \.id) { item in
              VStack(alignment: .leading) {
                  Text(item.quote)
              }
          }.onAppear(perform: loadData)
      }
      
    
      func loadData() {
          guard let url = URL(string: &quot;https://api.kanye.rest&quot;) else {
              print(&quot;Your API end point is Invalid&quot;)
              return
          }
          let request = URLRequest(url: url)
  
          URLSession.shared.dataTask(with: request) { data, response, error in
              if let data = data {
  
                  if let response = try? JSONDecoder().decode([TaskEntry].self, from: data) {
                      DispatchQueue.main.async {
                          print(response)
                          self.results = response
                      }
                      return
                  }
              }
          }.resume()
      }
      
  }
  
  struct ContentView_Previews: PreviewProvider {
      static var previews: some View {
          ContentView()
      }
  }
  
  
  </code></pre>
  <pre><code>import Foundation
  
  struct TaskEntry: Codable  {
      let id: UUID
      let quote: String
  }
  </code></pre>