# Fetch Data Using URLSession In swift (iOS)

## Before diving into making requests and mapping data to models first lets understand what is the URLSession?

*   It’s Swift’s built-in API to **make network requests** (like fetching data from the internet).
    
*   You use it to download JSON, images, or send data to a server.
    
*   Think of it as your app’s “internet worker.”
    

## Simple Mental Model to understand the flow of URLSession.

1.  Create a URL - (The address you want to get the data as response)
    
2.  Create a URLSession Task with - (we will create dataTask as we are hitting the url)
    
3.  Handle the response (success or error) in a completion handler.
