I currently using Moya and Alamofire for get data from server for iOS. and it worked perfectly before. However, only ios can't get data for some unknown reasons. for the postman and android is working for getting data from server.
if i just use Alamofire to get data is working but with moya is not working...
Does anyone knows or solved this problem?
Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x60400025fb90 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}
extension ServerRequestService: TargetType {
var baseURL: URL { return URL(string: CRConstant.API.requestHostForProduction)! }
var path: String {
switch self {
case .main: return "/main"
}
}
var method: Moya.Method {
switch self {
case .main: return .get
}
}
var task: Task {
switch self {
case .main: var param = [String: Any](); param["device"] = IOS
return .requestParameters(parameters: param, encoding: JSONEncoding.default)
}
}
ServerRequestService.request(.main) { [weak self] result in
guard let `self` = self else {
return
}
switch result {
case let .success(response):
print(response.data)
case let .failure:
print("failed")
}
}