Search code examples
swiftrequestalamofire

Alamofire.request "Extra argument 'method' in call"


I have the error above on the first request and I already tried to change the return from URL to URLConvertible?

func baseUrlWith(string: String) -> URL {
        return URL(string: Constants.Api.BaseUrl + string)!
}

func fetchVideosAlamofire(completion: @escaping ([Product]) -> ()) {
   let url = URL(string: Constants.Api.BaseUrl + Constants.Api.Feed)
   let url1 = baseUrlWith(string: Constants.Api.Feed)

   Alamofire.request(url1!,
                     method: .get,
                     parameters: nil).validate().responseJSON

   Alamofire.request(url!,
                     method: .get,
                     parameters: nil).validate().responseJSON
}

I'm using Alamofire 4.3.0


Solution

  • Use a URLRequest:

    var request = URLRequest(url: url!)
    request.httpMethod = "GET"
    
    Alamofire.request(request)
    .validate()
    .responseJSON { (response) in
        //
    }