Added client side repos
This commit is contained in:
15
src/Portfolio.Web/Services/TechnologyRepository.cs
Normal file
15
src/Portfolio.Web/Services/TechnologyRepository.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Portfolio.Shared.Models;
|
||||
using Portfolio.Shared.Services;
|
||||
|
||||
namespace Portfolio.Web.Services;
|
||||
|
||||
internal sealed class TechnologyRepository(IHttpClientFactory factory) : ITechnologyRepository {
|
||||
public async Task<IEnumerable<Technology>> GetTechnologies(CancellationToken ct) {
|
||||
var client = factory.CreateClient("api");
|
||||
var response = await client.GetAsync("api/technologies", ct);
|
||||
if (!response.IsSuccessStatusCode) return [];
|
||||
|
||||
var data = await response.Content.ReadFromJsonAsync<IEnumerable<Technology>>(ct);
|
||||
return data ?? [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user