---
title: "Discussion on \"Use Retrofit to fetch a list from an API and display it in a ViewModel using Kotlin\" | Hashnode"
description: "Discussion on \"Use Retrofit to fetch a list from an API and display it in a ViewModel using Kotlin\". First, define a data model class that represents the data you want to fetch from the API. For example:\n data class User(\n     val id: Int,\n     val name: String,\n     val email: String\n )\n\n\nNext, define an interface that defines the API endpoint for ..."
url: "https://hashnode.com/posts/use-retrofit-to-fetch-a-list-from-an-api-and-display-it-in-a-viewmodel-using-kotlin/63b1c1dea988605064ae5708"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Use Retrofit to fetch a list from an API and display it in a ViewModel using Kotlin](https://chrisroid.io/use-retrofit-to-fetch-a-list-from-an-api-and-display-it-in-a-viewmodel-using-kotlin?utm_source=hashnode&utm_medium=feed)

First, define a data model class that represents the data you want to fetch from the API. For example: data class User( val id: Int, val name: String, val email: String ) Next, define an interface that defines the API endpoint for ...

Jan 1, 2023 · 2 min read · chrisroid.io  
Read the article

-   [#retrofit](https://hashnode.com/tag/retrofit)
-   [#android](https://hashnode.com/tag/android)
-   [#viewmodel](https://hashnode.com/tag/viewmodel)
-   [#fetch-api](https://hashnode.com/tag/fetch-api)

## Written by

[Chris Asarhasa](https://hashnode.com/@Chrisroid)

@Chrisroid · Lagos, Nigeria

  
[View profile](https://hashnode.com/@Chrisroid)

Mobile Apps Developer

Committed to Tech

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
