Instaid of getting the species, get the pokemon itself

This commit is contained in:
Joren 2024-04-29 16:30:09 +02:00
parent 7b3131d510
commit f7bd501921
Signed by untrusted user who does not match committer: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -19,13 +19,13 @@ data class PokemonSpecies(
@SerializedName("url") val url: String @SerializedName("url") val url: String
) )
data class PokemonSpeciesResponse( data class PokemonResponse(
@SerializedName("results") val results: List<PokemonSpecies> @SerializedName("results") val results: List<PokemonSpecies>
) )
interface PokeApiService { interface PokeApiService {
@GET("pokemon-species/?offset=0&limit=1025") @GET("pokemon/?offset=0&limit=1025")
suspend fun getPokemonSpecies(): PokemonSpeciesResponse suspend fun getPokemon(): PokemonResponse
} }
class PokeSearchViewModel : ViewModel() { class PokeSearchViewModel : ViewModel() {
@ -48,7 +48,7 @@ class PokeSearchViewModel : ViewModel() {
private fun fetchPokemonSpecies() { private fun fetchPokemonSpecies() {
viewModelScope.launch { viewModelScope.launch {
try { try {
val response = service.getPokemonSpecies() val response = service.getPokemon()
_initialPokemonList.value = response.results _initialPokemonList.value = response.results
_filteredPokemonList.value = listOf(PokemonSpecies("Please enter a search term", "")); _filteredPokemonList.value = listOf(PokemonSpecies("Please enter a search term", ""));
} catch (e: IOException) { } catch (e: IOException) {