Response

public struct Response

Struct for a Response. A Response represents a response received from a network request.

  • property data: The data received from the network request.
  • property response: The URLResponse received from the network request.
  • Declaration

    Swift

    public let data: Data
  • Declaration

    Swift

    public let response: URLResponse
  • Initializes a new instance of Response.

    Declaration

    Swift

    public init(data: Data, response: URLResponse)
  • Returns the body of the response.

    Declaration

    Swift

    public func body() -> String

    Return Value

    The body of the response as a String.

  • Returns the body of the response as a JSON object.

    Declaration

    Swift

    public func json(data: Data) throws -> [String : Any]

    Parameters

    data

    The data to convert to a JSON object.

    Return Value

    The body of the response as a JSON object.

  • Returns the status code of the response.

    Declaration

    Swift

    public func status() -> Int

    Return Value

    The status code of the response as an Int.

  • Returns the value of a specific header from the response.

    Declaration

    Swift

    public func header(name: String) -> String?

    Parameters

    name

    The name of the header.

    Return Value

    The value of the header as a String.

  • Returns the cookies from the response.

    Declaration

    Swift

    public func getCookies() -> [HTTPCookie]

    Return Value

    The cookies from the response as an array of HTTPCookie.

  • Constants used in the Response

    See more

    Declaration

    Swift

    public enum Constants