Skip to content

Naxilos/httpclient-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

httpclient-demo

try
{
    using HttpResponseMessage response = await client.GetAsync("https://dummyjson.com/products?limit=20");

    string responseBody = await response.Content.ReadAsStringAsync();

    GetProductsResponse obj = Newtonsoft.Json.JsonConvert.DeserializeObject< GetProductsResponse>(responseBody);

    ProductsCollection.ItemsSource = obj.Products;
}
catch(HttpRequestException ex)
{
    await Shell.Current.DisplayAlert($"Error {(int)(ex.StatusCode ?? System.Net.HttpStatusCode.OK)}", ex.Message, "Oh snap!");
}
catch (Exception ex)
{
    await Shell.Current.DisplayAlert($"Unknown Error", ex.Message, "Oh snap!");
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages