Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save luismendes070/81eec98c069d04e125a8426088aee9c9 to your computer and use it in GitHub Desktop.
Save luismendes070/81eec98c069d04e125a8426088aee9c9 to your computer and use it in GitHub Desktop.
Xamarin Essentail Training Create Your First App LinkedIn Learning
Visual Studio 2022 x64 Community
dotnet add package System.Text.Json --version 6.0.0
https://www.linkedin.com/learning/xamarin-essential-training-create-your-first-app-16074381/xamarin-essential-training
@luismendes070
Copy link
Author

luismendes070 commented Nov 16, 2022

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace ProductService.Library
{
public class ProductService
{
private const string API_URL = "https://hplusport.com/api";
private static HttpClient _client;

static ProductService()
{
    _client = new HttpClient();
}

public async Task<List> GetProducts()
{
try
{
var response = await _client.GetAsync(API_URL + "/products");
var products = await response.Content.ReadFromJsonAsync<List>();
return products;
}
catch()
{
return new List();
}
}

}}

@luismendes070
Copy link
Author

luismendes070 commented Nov 16, 2022

using System;

namespace ProductApp.Library
{

public class Product
{
    public string Name { get; set; }
    // win ctl + b 
    // mac cmd + b
    public string Description { get; set; }
 }

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment