title: Swift4 Invalid conversion from throwing function of type '(_, _, _) throws -> ()' to non-throwing function type '(Data?, URLResponse?, Error?)
body: <pre><code>func DoLogin(_ email:String, _ password:String)
  {
      struct User: Decodable {
          let sfname: String
          let slname: String
          let email: String
          let sid: Int
      }
  
      let url = URL(string: "http://URL")!
      var request = URLRequest(url: url)
      request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
      request.httpMethod = "POST"
      let postString = "email=" + email + "&amp;password=" + password + ""
      request.httpBody = postString.data(using: .utf8)
      let task = URLSession.shared.dataTask(with: request) { data, response, error in
          guard let data = data, error == nil else {                                                 // check for fundamental networking error
              print(error!)
              return
          }
  
          if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {           // check for http errors
              print("statusCode should be 200, but is \(httpStatus.statusCode)")
              print(response!)
          }
  
         if let responseString = String(data: data, encoding: .utf8){
          let myStruct = try JSONDecoder().decode(User.self, from: responseString)
          }
      }
  
      task.resume()
  }
  </code></pre>
  
  <p>So the aim is to decode the HTTP response <code>responseString</code> in order to save the information into the properties of <code>User</code>, but I keep getting the same error popping up after inserting the line of code in order to decode the HTTP response (<code>myStruct</code>). I feel it has something to do with Do Try Catch error handling but can't manage to figure it out.</p>
  
  <p>Thanks in advance for the help :)</p>