0Pricing
Kotlin Multiplatform Academy · Ders

İlk GET İsteğiniz

Paylaşılan kodda bir API'den JSON alın.

İlk GET İsteğiniz, CoddyKit'te ücretsiz bir Kotlin Multiplatform Academy dersidir. Bu, 4 dersinin 2. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, Kotlin Multiplatform Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Kotlin Multiplatform Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Fetch From Shared Code

With the client ready, you can now make your first GET request from commonMain and reuse it on both apps. 🚀

Network Calls Suspend

Every Ktor request is a suspend function, so it never blocks a thread and fits naturally into coroutines.

suspend fun load() { /* request here */ }

Call get With a URL

The simplest request passes a URL string to client.get, which returns an HttpResponse you can read from.

val response = client.get("https://api.example.com/users")

Read the Status Code

Check whether the call succeeded by reading response.status before you trust the body.

if (response.status.value == 200) { /* ok */ }

Get the Body as Text

To read the payload, call bodyAsText, which suspends and returns the raw response as a String.

val json: String = response.bodyAsText()

Typed Bodies Are Cleaner

Ktor can deserialize directly into a type using body, saving you from parsing the text by hand later.

val users: List<User> = response.body()

One-Line GET

You can also skip the response object entirely and let get return your typed result in a single expression.

val users: List<User> = client.get(url).body()

Wrap in a Function

Put the call inside a clean suspend function so both apps share the exact same fetching logic.

suspend fun fetchUsers() = client.get(url).body<List<User>>()

Run It From a Scope

Because the call suspends, you launch it inside a coroutine scope rather than calling it from plain synchronous code.

scope.launch { val users = fetchUsers() }

It Works on Both Apps

This single function now runs on Android and iOS with no changes, because the engine differences live below the API.

Keep Calls in the Repository

For real apps, hide raw get calls inside a repository so the UI never touches Ktor directly.

Quick Check

How do you read the raw response payload as a String?

Recap

A GET request is a suspend call: get the URL, check status, then read the body as text or a typed object. One function serves both apps.

Sıkça Sorulan Sorular

“İlk GET İsteğiniz” dersi ücretsiz mi?

Evet — “İlk GET İsteğiniz” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve Kotlin Multiplatform Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Kotlin Multiplatform Academy kursu toplamda 4 dersten oluşur.

“İlk GET İsteğiniz” dersinde ne öğreneceğim?

Paylaşılan kodda bir API'den JSON alın. Kotlin Multiplatform Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

Kotlin Multiplatform Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Kotlin Multiplatform Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 2. dersidir.

“İlk GET İsteğiniz” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu Kotlin Multiplatform Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Kotlin Multiplatform Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Ktor Ekleme ve Platform Motorlarını Seçme
  2. İlk GET İsteğiniz
  3. POST, Üst Bilgiler ve Sorgu Parametreleri
  4. Zaman Aşımları, Günlükleme ve Temel URL'ler
← Kotlin Multiplatform Academy Sayfasına Dön