async/await is a modern Swift concurrency feature used to handle asynchronous operations in a synchronous-looking way.
In networking, it replaces completion handlers with a clean and linear flow.
Request
↓
await response
↓
process result
↓
handle errors
Instead of using dataTask, async/await uses:
let (data, response) = try await URLSession.shared.data(for: request)
This performs the network request and waits for the result.
Functions using async/await must be marked as:
func getUsers() async
Async functions are called using:
Task {
await getUsers()
}