Migration from Alamofire 2 to Alamofire 4. Extra Argument in call (Request)

Asked

Viewed 27 times

0

When making requests to the server used the following code

let URL = Foundation.URL(string: "http:....")!
let mutableURLRequest = NSMutableURLRequest(url: URL)
mutableURLRequest.httpMethod = "POST"

let parameters = ["UserName": "Teste"]
  do{
    mutableURLRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters, options: JSONSerialization.WritingOptions())
    }catch{}

mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")

Alamofire.request("https").responseJSON{response in....}

Now with the migration to Swift 4 I’ve tried the codes that are in the library document and tried other options that several users give both here and in forums and I usually have the same error that is the following "Extra argument in call"

Someone with the same problem and who I have managed to reach the solution can help me?

  • Would not be Alamofire.request(mutableURLRequest).responseJSON{response in....}?

1 answer

0

I was able to solve the problem of the "Extra Argument" error using the code I demonstrated above but changed the Nsmutableurlrequest to Urlrequest

Browser other questions tagged

You are not signed in. Login or sign up in order to post.