I'm sending requests using Alamofire as below. I need to know how can I set the timeout only for a specific request like this
Alamofire.request(URL, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).validate().responseJSON { (response) in switch response.result {
////
}
Try to create a sessionManager for that specific request
let sessionManager: SessionManager = {
var sessionManager = SessionManager()
let configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = 30 //timeout can be changed from here
sessionManager = Alamofire.SessionManager(configuration: configuration)
return sessionManager
}()
and use this sessionManager
for the call.
sessionManager.request(url, method: .get, parameters: params)...