NNovaNetworkClientSwift networkingGitHub ↗

Beginner · 10 min

Build your first request

Decode a public API response into a small Sendable model.

You’ll buildA complete async Swift program that loads a typed Todo value.
1
Step 1

Describe the response

Model only the fields the feature owns. Sendable keeps the value safe across concurrency boundaries.

Buildyourfirstrequest.swift
struct Todo: Decodable, Sendable {
    let id: Int
    let title: String
    let completed: Bool
}
2
Step 2

Build an APIRequest

Keep URL, method, headers, and body together in a stable value.

Buildyourfirstrequest.swift
let request = APIRequest(
    method: .get,
    url: URL(string: "https://jsonplaceholder.typicode.com/todos/1")!,
    headers: ["Accept": "application/json"]
)
3
Step 3

Load a typed response

The generic return type tells the client what to decode.

Buildyourfirstrequest.swift
let client = NetworkClient(transport: Transport())
let todo: Todo = try await client.load(
    request: request,
    authScope: "public"
)
✓

Tutorial complete

A complete async Swift program that loads a typed Todo value.