URLSession
public extension URLSession
AsyncCompatibilityKit Copyright © John Sundell 2021 MIT license, see LICENSE.md file for details
-
data(from:Asynchronous) Start a data task with a URL using async/await.
Throws
Any error encountered while performing the data task.Declaration
Swift
func data(from url: URL) async throws -> (Data, URLResponse)Parameters
urlThe URL to send a request to.
Return Value
A tuple containing the binary
Datathat was downloaded, as well as aURLResponserepresenting the server’s response. -
data(for:Asynchronous) Start a data task with a
URLRequestusing async/await.Throws
Any error encountered while performing the data task.Declaration
Swift
func data(for request: URLRequest) async throws -> (Data, URLResponse)Parameters
requestThe
URLRequestthat the data task should perform.Return Value
A tuple containing the binary
Datathat was downloaded, as well as aURLResponserepresenting the server’s response.
View on GitHub