Instaid of getting the species, get the pokemon itself
This commit is contained in:
parent
7b3131d510
commit
f7bd501921
@ -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) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user