Home:ALL Converter>Unable to get data with RETROFIT + COROUTINE

Unable to get data with RETROFIT + COROUTINE

Ask Time:2021-09-22T05:15:44         Author:Chelsea Katsidzira

Json Formatter

I'm trying to make a simple network call with Retrofit and doing it asynchronously with coroutines, but when I run the app, there is absolutely no response. No information. I can't tell if the call is being made. Please help.

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import kotlinx.coroutines.*
import retrofit2.*
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET

class MainActivity : AppCompatActivity() {
    val TAG = "MainActivity"
    var job: Job? = null

    override fun onCreate(savedInstanceState: Bundle?) {

        val api = Retrofit.Builder()

        GlobalScope.launch(Dispatchers.IO) {
            val response = api.getAllMovies()
            if (response.isSuccessful) {
                val movies = response.body()
                if (movies != null) {
                    for (movie in movies) {
                        Log.d(TAG, movie.name)




interface RetrofitService {
    suspend fun getAllMovies() : Response<List<Movie>>

data class Movie(val name: String, val imageUrl: String, val category: String)

Author:Chelsea Katsidzira,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69275637/unable-to-get-data-with-retrofit-coroutine