Useful Swift iOS and MacOS Async HTTP Client.
Motto: Perform http requests in one string
dependencies: [
.package(url: "https://github.com/Oleg-E-Bakharev/AsyncHttpClient", from: "1.1.0")
],
#import Foundation
#import AsyncHttpClient
struct Warehouse: Codable {
let id: Int
let title: String
}
let httpClient: AsyncHttpClient = AsyncHttpJSONClient()
func fetchWarehouses() async throws -> [Warehouse] {
try await httpClient.get(url: URL(string: "https://my_sweet_url.com/warehouses"))
}
func update(warehouse: Warehouse) async throws {
try await httpClient.post(url: URL(string: "https://my_sweet_url.com/warehouse"), body: warehouse)
}