Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline
i'm hiting an API in postman there i'm getting response fine. But when i hit same API in my iOS App its shows me nil response and result is error. I have printed the error,it shows me this, Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline.
I have checked my internet connection it is working fine.I have searched different sites the internet connection if fine. But all the time it shows me this error. I'm confuse that why it is showing me this error. My code to hit api is this,
Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline.
class WalletDetailService
static let instance = WalletDetailService()
var getWalletDetailModelArray = [WalletDetail]()
var status:Int = 0
func getWalletDetails(param:[String : String],completion:@escaping CompletionHandler)
let header = [
"auth": "2dd7cfb3c40b4830b72be2cc90276fd9"
]
print(header)
let url = URL(string: getWalletDetailsUrl)
Alamofire.request(url!, method: .post, parameters: param, encoding: JSONEncoding.default, headers: header).responseJSON (response) in
print("Request: (String(describing: response.request))") // original url request
print("Response: (String(describing: response.response))") // http url response
print("Result: (response.result)")// response serialization result
if response.result.error == nil
guard let data = response.data else return
do
if let json = try JSON(data: data).dictionary
let result = json["result"]?.dictionary
let monthlyRental = result!["monthly_rental"]?.intValue
print(monthlyRental!)
completion(true)
completion(true)
catch let jsonErr
print(jsonErr)
else
completion(false)
debugPrint(response.result.error as Any)
}
0
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.