Blazor & WASM in combination to get statistics from Spotify API for performing the song analysis. With separate microservices for auth, Spotify, user data tracking, and application, connected through gRPC with Polly.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

HttpUtils.cs 638B

123456789101112131415161718192021222324
  1. using Grpc.Net.Client;
  2. using Microsoft.Net.Http.Headers;
  3. using Newtonsoft.Json;
  4. namespace SpotifyService.HttpUtils
  5. {
  6. public static class HttpUtils<T>
  7. {
  8. public static async Task<T> GetData(HttpClient client, string url, string token)
  9. {
  10. //add header
  11. client.DefaultRequestHeaders.Add(HeaderNames.Authorization, "Bearer " + token);
  12. //get request
  13. var req = await client.GetAsync(url);
  14. //read response
  15. var response = JsonConvert.DeserializeObject<T>(await req.Content.ReadAsStringAsync())!;
  16. return response;
  17. }
  18. }
  19. }