Type of expression is ambivalent without more context error (Swift)

Asked 2 months ago, Updated 2 months ago, 1 views

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)")
    }
}

swift xcode

2022-09-30 14:29

1 Answers

let(data, response) = try away URLSession.shared.data(from:url)

Then what happens?


2022-09-30 14:29

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.