Last active
July 20, 2020 19:11
-
-
Save TBertuzzi/fc7e01441276634c47fb2c96b05b9528 to your computer and use it in GitHub Desktop.
HttpExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task<List<Pokemon>> GetPokemonsAsync() | |
{ | |
List<Pokemon> pokemons = new List<Pokemon>(); | |
try | |
{ | |
var httpClient = new HttpClient(); | |
for (int i = 1; i < 20; i++) | |
{ | |
Pokemon pokemon = | |
await $"{Constantes.ApiBaseUrl}pokemon/{i}".GetJsonAsync<Pokemon>(); | |
pokemons.Add(pokemon); | |
} | |
} | |
catch (Exception ex) | |
{ | |
Debug.WriteLine(ex.Message); | |
} | |
return pokemons; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment