I'm creating a function which makes an API request. The function receives a parameter and put it inside the API call. It is like this:
static func queryCities(cityNameString : String, completion: @escaping (City)->()){
let urlString = "http://api.geonames.org/searchJSON?q=\(cityNameString)&username=myusername"
guard let url = URL(string: urlString) else {return}
print(url)
}
But only when I try to convert my String into a URL the function doesn't return anything. I need to precise that the API call is working well if I paste it in safari. How can I solve this problem?