FMPWeb

Description

The FMPWeb class is used to describe request to web resource.

class FMPWeb

Properties

Property Description

httpMethod

HTTP method.
var httpMethod: FMPWeb.HTTPMethod { get }
headers Request headers.
var headers: [AnyHashable : Any] { get }
resource Web resource, for which request is created.
var resource: FMPResource? { get }

queryParams

Request string parameters.
var queryParams: [AnyHashable : Any] { get }

Methods

Method Description

request(completion:)

Send request to web resource.
func request(completion: @escaping FMPRequestResponseHandler)

Parameters:

  • completion. Closing expression containing method execution result.

Example

Send request to web resource:

// Build an instance of the FMPWeb class. For details see examples for FMPWeb.Builder.
let web: FMPWeb = fmp.web.build()
  
// Send request to web resource
web.request() { (response) in
    if response.success {
        // Display server response
        print(response.result)
    } else {
        // Display error code and description
        print(response.error?.code, response.error?.description)
    }
}

See also:

FMPWrapper Framework | Classes