title: How can I display an image by an API URL? Swift
body: <p>I have an app in which it shows me data from an API. I made a service that gets the data, where URL(string = "") is the url of the API:</p>
  
  <pre><code>class Webservice {
  
      func getAllMatches(completion: @escaping ([Matches.Matchs]?) -&gt; ()) {
  
          guard let url = URL(string: "API")
              else {
                  fatalError("URL is not correct!")
          }
          URLSession.shared.dataTask(with: url) { data, _, _ in
  
              let matchs = try! JSONDecoder().decode([Matches.Matchs].self, from: data!)
              DispatchQueue.main.async {
                  completion(matchs)
              }
          }.resume()
      }
  
  }
  </code></pre>
  
  <p>Then I made a ViewModel in which the API fields were set:</p>
  
  <pre><code>class MatchListViewModel: ObservableObject {
  
      @Published var matches = [MatchViewModel]()
  
  
      init() {
          fetchMatch()
  
  
      }
  
      func fetchMatch() {
  
          Webservice().getAllMatches { matches in
  
              if let matches = matches {
                  self.matches = matches.map(MatchViewModel.init)
              }
          }
      }
  
  }
  
  
  class MatchViewModel {
  
      let id = UUID()
  
      var match: Matches.Matchs
  
      init(match: (Matches.Matchs)) {
          self.match = match
      }
  
  
      var championship: String {
          return self.match.championship.name
      }
  
      var local_Name: String {
          return self.match.local.name
      }
  
      var local_Image: String  {
          return self.match.local.image
      }
  
      var local_goals: Double {
          return self.match.local_goals
      }
  
      var local_penalty_goals: Double {
          return self.match.local_penalty_goals
      }
      var stadium_Name: String {
          return self.match.stadium.name
      }
  
  }
  </code></pre>
  
  <p>In the API, there is a field that shows an image, which is contained in a URL, I leave an example:</p>
  
  <pre><code>"local":{  
       "slug":"nombre",
       "name":"nombre",
       "short_name":"nombre",
       "image":"https://s3.amazonaws.com/funx-futbol/dashboard/ad.png"
   },
  </code></pre>
  
  <p>My question is: How can I display that image via that URL? The API query works, as it brings me the information I require, but I need to show me the image through that link, which I have not achieved.</p>
  
  <p>Thanks for reading!</p>
  
  <p><a href="https://i.stack.imgur.com/Tc1Md.png" rel="nofollow noreferrer">error</a></p>