Skip to content

Instantly share code, notes, and snippets.

@Adolfi
Created October 6, 2022 09:32
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 Adolfi/cec10173dad5dc0a9227c4b4647cd674 to your computer and use it in GitHub Desktop.
Save Adolfi/cec10173dad5dc0a9227c4b4647cd674 to your computer and use it in GitHub Desktop.
public class PageApiController : UmbracoApiController
{
private readonly ILogger<PageApiController> logger;
private readonly HttpClient httpClient;
public PageApiController(IHttpClientFactory httpClientFactory, ILogger<PageApiController> logger)
{
this.httpClient = httpClientFactory.CreateClient(NamedHttpClient.LoggingHttpClient);
this.logger = logger;
}
public async Task<HttpResponseMessage> CallExternalApi()
{
var request = new HttpRequestMessage(HttpMethod.Get, "https://google.com");
return await httpClient.SendAsync(request);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment