|
|
@ -1,5 +1,8 @@ |
|
|
|
using FluentBlazorApp.DTOs; |
|
|
|
using FluentBlazorApp.DTOs; |
|
|
|
using FluentBlazorApp.Responses; |
|
|
|
using FluentBlazorApp.Responses; |
|
|
|
|
|
|
|
using FluentBlazorApp.States; |
|
|
|
|
|
|
|
using System.Net.Http; |
|
|
|
|
|
|
|
using System.Net.Http.Headers; |
|
|
|
using static FluentBlazorApp.Responses.CustomResponses; |
|
|
|
using static FluentBlazorApp.Responses.CustomResponses; |
|
|
|
|
|
|
|
|
|
|
|
namespace FluentBlazorApp.Services |
|
|
|
namespace FluentBlazorApp.Services |
|
|
@ -29,8 +32,13 @@ namespace FluentBlazorApp.Services |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async Task<WeatherForecastDTO[]> GetWeatherForecastsAync() |
|
|
|
public async Task<WeatherForecastDTO[]> GetWeatherForecastsAync() |
|
|
|
=> await _httpClient.GetFromJsonAsync<WeatherForecastDTO[]>($"{BASE_URL}/weather"); |
|
|
|
{ |
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(Constants.JWTToken)) |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Constants.JWTToken); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return await _httpClient.GetFromJsonAsync<WeatherForecastDTO[]>($"{BASE_URL}/weather"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|