Skip to content

hackenbacker/WebClient

Repository files navigation

🕸️ WebClient

Swift Swift Package Manager Platforms

Web Client library to get data from an API endpoint.


Usage

import WebClient

struct Album: Codable {
    var userId: Int
    var id:     Int
    var title:  String
}

do {
    let host = "https://jsonplaceholder.typicode.com/albums"
    let request = URLRequest(url: URL(string: host)!)

    let albums = try await WebClient.fetch([Album].self, for: request)

    for album in albums {
        print(album.title)
    }

} catch {
    print(error)
}

Requirements

  • Xcode 14.2 or later
  • iOS 15.0 or later

Dependencies

  • none