Skip to content

Instantly share code, notes, and snippets.

@Adolfi
Created Oct 6, 2022
Embed
What would you like to do?
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