Skip to content

Instantly share code, notes, and snippets.

@TBertuzzi
Last active July 20, 2020 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TBertuzzi/fc7e01441276634c47fb2c96b05b9528 to your computer and use it in GitHub Desktop.
Save TBertuzzi/fc7e01441276634c47fb2c96b05b9528 to your computer and use it in GitHub Desktop.
HttpExtension
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