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

    url

    The URL to send a request to.

    Return Value

    A tuple containing the binary Data that was downloaded, as well as a URLResponse representing the server’s response.

  • data(for:) Asynchronous

    Start a data task with a URLRequest using async/await.

    Throws

    Any error encountered while performing the data task.

    Declaration

    Swift

    func data(for request: URLRequest) async throws -> (Data, URLResponse)

    Parameters

    request

    The URLRequest that the data task should perform.

    Return Value

    A tuple containing the binary Data that was downloaded, as well as a URLResponse representing the server’s response.