title: Blazor Webassembly - calling external API
body: <p>I have been trying to call a separate asp.net core web api from with in a Blazor client side web assembly.   I used the templates web API template with this controller.  I have CORS set up in the startup.cs.  I am using the standard HTTP client with in the Blazor Client.  Running locally I can set a break point on the API code and see it get hit.  But the client is throwing an exception: <strong>Type Error</strong></p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>David</p>
  
  <pre><code>[Route("[controller]")]
  public class WeatherForecastController : ControllerBase
  {
      private static readonly string[] Summaries = new[]
      {
          "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
      };
  
      private readonly ILogger&lt;WeatherForecastController&gt; _logger;
  
      public WeatherForecastController(ILogger&lt;WeatherForecastController&gt; logger)
      {
          _logger = logger;
      }
  
      [HttpGet]
      public IEnumerable&lt;WeatherForecast&gt; Get()
      {
          var rng = new Random();
          return Enumerable.Range(1, 5).Select(index =&gt; new WeatherForecast
          {
              Date = DateTime.Now.AddDays(index),
              TemperatureC = rng.Next(-20, 55),
              Summary = Summaries[rng.Next(Summaries.Length)]
          })
          .ToArray();
      }
  }
  
  Startup.cs
       services.AddCors(options =&gt;
              {
                  options.AddPolicy(name: MyAllowSpecificOrigins,
                                    builder =&gt;
                                    {
                                        builder.WithOrigins("http://example.com",
                                                            "http://www.contoso.com")
                                                            .AllowAnyOrigin()
                                                            .AllowAnyMethod()
                                                            .AllowAnyHeader();
                                    });
              });
  
  Blazor Client
  var response = await Http.GetFromJsonAsync&lt;WeatherForecast[]&gt;("WeatherForecast");
  </code></pre>