You cant return value from inside closer so you need to add closure to your function
func getURL(name: String , completion: @escaping (_ youstring : String) -> (Void) ) -> Void {
let headers: HTTPHeaders = [
"Cookie": cookie
"Accept": "application/json"
]
let url = "https://api.google.com/" + name
Alamofire.request(url, headers: headers).responseJSON {response in
if((response.result.value) != nil) {
let swiftyJsonVar = JSON(response.result.value!)
print(swiftyJsonVar)
let videoUrl = swiftyJsonVar["videoUrl"].stringValue
print("videoUrl is " + videoUrl)
completion (youstring : )
// error happens here
}
}
}