Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

what is the correct way to connect multiple api to 1 blazor website?

$
0
0

I have a blazor server web app and multiple API's. Each of those api's lead to a different location.I currently change the location to where it needs to go based on a parameter that i then pass along to every function like so:

    public class ActiviteitenClient(HttpClient httpClient)    {        private readonly HttpClient _httpClient = httpClient;        public async Task<List<OActiviteit>> GetAsync(string adres = "")        {            _httpClient.BaseAddress = new(adres);            var y = await _httpClient.GetAsync($"/api/Activiteit");            var z = JsonSerializer.Deserialize<List<OActiviteit>>(await y.Content.ReadAsStringAsync());            return z;        }...

there has to be a better way to do this. Can anyone enlighten me how?


Viewing all articles
Browse latest Browse all 4839

Trending Articles