var url:String = "http://112.199.178.73:4000/contact" + "?" + ["accessToken": getAppDelegate().applicationData?.accessToken].queryStringWithEncoding();
var socketUrl = URL(string: url);
Don't build out URLs and URL strings manually like that.
var components = URLComponents()
components.scheme = "http"
components.host = "112.199.178.73"
components.port = 4000
components.path = "/contact"
// I'm assuming accessToken is a string here
if let accessToken = getAppDelegate().applicationData?.accessToken {
components.queryItems = [
URLQueryItem(name: "accessToken", value: accessToken)
]
}
guard let url = components.url else {
fatalError("Failed to create URL")
}
If you could post the string that var url:String = "http://112.199.178.73:4000/contact" + "?" + ["accessToken": getAppDelegate().applicationData?.accessToken].queryStringWithEncoding();
generates we could tell you exactly what's going wrong, but I bet that however ["accessToken": getAppDelegate().applicationData?.accessToken].queryStringWithEncoding();
is getting appended to that string is going to give you an improper url string.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments