Skip to content

decodeUrl(__with_apiKey_body_method_bodyRequired_formSubmission_)

MarcoDotIO edited this page Dec 5, 2022 · 1 revision

decodeUrl(_:with:apiKey:body:method:bodyRequired:formSubmission:)

Decode a URL to the type T using either asyncData() for the Production Server; or using decode() for the Mock Server.

public func decodeUrl<T: Decodable>(
        _ type: T.Type = T.self,
        with url: URL,
        apiKey: String? = nil,
        body: [String: Any]? = nil,
        method: HTTPMethod = .post,
        bodyRequired: Bool = true,
        formSubmission: Bool = false
    )

Parameters

  • type: The type of T that the data will decode to.
  • with: The input url of type URL that will be fetched.
  • apiKey: The API Key for use with the server.
  • body: The POST body used to add parameters, defaults to nil.
  • method: The method used for the function, defaults to .post.
  • bodyRequired: Is the body required or not, used for .get and .delete, defaults to false.
  • formSubmission: Is the body actually a form submission? Used for image submissionss, defaults to false.

Returns

The decoded object of type T.

Types
Global Functions
Clone this wiki locally