Alamofire.request"额外参数'方法'在电话"

时间:2017-01-17 15:50:43

标签: swift request alamofire

我在第一次请求时遇到上述错误,我已尝试将回复率从URL更改为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
}

我正在使用Alamofire 4.3.0

1 个答案:

答案 0 :(得分:1)

使用URLRequest

var request = URLRequest(url: url!)
request.httpMethod = "GET"

Alamofire.request(request)
.validate()
.responseJSON { (response) in
    //
}