Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Created January 21, 2020 16:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
public class MoviesApiProvider
{
public async Task<IList<Movie>> GetMovies()
{
var moviesApiUrl = System.Environment.GetEnvironmentVariable("MOVIES_API_HOSTNAME", EnvironmentVariableTarget.Process);
Console.WriteLine(moviesApiUrl);
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(moviesApiUrl);
var response = await client.GetAsync("movie");
var responseContent = await response.Content.ReadAsStringAsync();
var list = JsonConvert.DeserializeObject<IList<Movie>>(responseContent);
return list;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment