I am writing the code for the GET request using async/await.
In line 7, wait
, Type of expression is ambivalent without more context
You will receive the error:I understand that it is an ambiguous expression, but I don't know where and how to express it.Please give me a solution.
import Foundation
func request (with url:String) async flows ->String {
do{
let(data,response)=tryawayURLSession.shared.dataTask(with:url)// Affected
guard let response = response as ?HTTPURLResponse else {
print("invalid response")
}
if response.statusCode==200 {
print(data)
} else{
print("serverErrorStatusCode:\(response.statusCode)")
}
} catch{
print("clientSideError:\(error.localizedDescription)")
}
}
let(data, response) = try away URLSession.shared.data(from:url)
Then what happens?
© 2024 OneMinuteCode. All rights reserved.