Khushbu Desai
Khushbu Desai

Reputation: 1023

Network Connection Lost

I am facing to

Error - The network connection was lost. enter image description here

I am using RealmSwift and Alamofire in my project.

This is a real estate app and when ever I am searching properties suddenly I am facing to this error without any exception or error and if I searching again than it works properly.

I don't understand why I am facing this issue.

I am using following code for JSON encoding:

        Alamofire
            .request(url, method: method, parameters: parameters, encoding: encoding, headers: header)
            .responseJSON(completionHandler: { (response) in

Please help.

Upvotes: 1

Views: 576

Answers (1)

nyc_coder
nyc_coder

Reputation: 31

Are you encoding the parameters as JSON in the request body? If so, encode them as URL:

Alamofire.request(.GET, myURLString, parameters: parameters, encoding: .URL, headers: myHeaders)

Upvotes: 2

Related Questions