I try to parse json with swift using following:
let apiPath = "http://samples.openweathermap.org/data/2.5/forecast?q=München,DE&appid=b1b15e88fa797225412429c1c50c122a1"
func getDataWithCompletionHandler(completionHandler: (_ jsonData: JSON?) -> Void) {
let request : URLRequest = URLRequest(url: URL(string: apiPath)!)
Alamofire.request(apiPath, method: .get)
.responseJSON { (response) in
When my app running i got an error on line:
let request : URLRequest = URLRequest(url: URL(string: apiPath)!)
fatal error: unexpectedly found nil while unwrapping an Optional value.
But i did pass correct string. Why is that error happen?