Skip to main content

post(url:headers:body:)

Posts data to the specified URL using the POST method.

Declaration

func post(url: URL, headers: [String : String] = [:], body: Data? = nil) async throws -> (Data, URLResponse)

Parameters

url

The URL of the resource to post data to.

headers

Optional dictionary of headers to include in the request (default: empty).

body

Optional data to send in the request body (default: nil).

Return Value

A tuple containing the retrieved data and the URL response.

Discussion

Note

Any error that may occur during the network request.