title: @inject HttpClient httpClient vs builder.Services.AddHttpClient in Blazor
body: <p>Is there any reason why we don't have <code>GetFromJsonAsync</code> method available when we use named HttpClients. I had to Install NewtonSoftJson to deserialize the response when I switched to Named HttpClients.</p>
  <p><strong>Injecting in Razor Component</strong></p>
  <pre><code>@inject HttpClient httpClient
  
  @code{
  
      public async Task GetProfileAsync()
      {
          User user = await httpClient.GetFromJsonAsync&lt;User&gt;(&quot;user/getprofile/10&quot;);
      }
  }
  </code></pre>
  <p><strong>Injecting in a service/class</strong></p>
  <pre><code>        public ProfileViewModel(HttpClient httpClient)
          {
              _httpClient = httpClient;
          }
  
          public async Task GetProfileAsync()
          {
              var requestMessage = new HttpRequestMessage(HttpMethod.Get, &quot;user/getprofile/10&quot;);
              var response = await _httpClient.SendAsync(requestMessage);
              var responseBody = await response.Content.ReadAsStringAsync();            
              User user = JsonConvert.DeserializeObject&lt;User&gt;(responseBody);
          }
  </code></pre>
  <p>Thanks
  Fahad Mullaji</p>