0PricingLogin
SwiftUI Academy · Lesson

Calling APIs with URLSession

Fetch data using async/await.

What URLSession Does

URLSession is Apple framework for talking to the network. You give it a URL and it fetches the response for you. 🌐

Building a URL

Start with a valid URL. The initializer is optional because text can be malformed, so unwrap it before using.

let url = URL(string: "https://api.example.com/users")!

All lessons in this course

  1. Decoding JSON with Codable
  2. Calling APIs with URLSession
  3. The .task Modifier
  4. Loading & Error States
← Back to SwiftUI Academy