我在第一个请求中遇到了上述错误,我已经尝试将返回值从 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
最佳答案
使用URLRequest
:
var request = URLRequest(url: url!)
request.httpMethod = "GET"
Alamofire.request(request)
.validate()
.responseJSON { (response) in
//
}
关于swift - Alamofire.request "Extra argument ' 方法'在调用中”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41701489/