Reputation: 1733
In swift 3 i am Using alamofire for network calls . For this i am appending Base URL with the string.Because of which i am getting the response as nil. Please find the code below:
public var baseURL: URL { return URL(string: "http://138.112.175.138:3300/api")! }
public var path: String {
switch self {
case .carsSearch:
return "/cars/display?model=1"
default:
return ""
}
}
For appending this :
public func url() -> String {
return self.baseURL.appendingPathComponent(self.path).absoluteString
}
But i am getting the output as :
http://138.112.175.138:3300/api/cars/display%3Fmodel=1
Because of this my response is getting nil. How to resolve this issue?
Upvotes: 2
Views: 1462
Reputation: 771
Try to remove persent encoding:
public func url() -> String {
return self.baseURL.appendingPathComponent(self.path).absoluteString.removingPercentEncoding
}
Upvotes: 2