我在第一次请求时遇到上述错误,我已尝试将回复率从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
答案 0 :(得分:1)
使用URLRequest
:
var request = URLRequest(url: url!)
request.httpMethod = "GET"
Alamofire.request(request)
.validate()
.responseJSON { (response) in
//
}