# Calling a REST service from JavaScript
```js
fetch(
  "https://localhost:5001/WeatherForecast?location=" + requestedLocation,
  {
      method: 'GET'
  })
.then(response =>
{ 
    ...       
})
.catch(err =>
{
    this.Available = false;
    this.Notice = "The following fatal error occurred while contacting the API: " + err;
});
```
- `fetch` is a JavaScript function which returns a Promise
- `then` is a bind for the Promise
If you're getting an error saying that the service is not usable due to a CORS policy and you're using ASP.NET Core, include the following code in your `Configure` method:
```csharp
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
	app
		.UseCors(builder =>
			builder
				.AllowAnyOrigin()
				.AllowAnyHeader()
				.AllowAnyMethod());
}
```
(not a good idea for an actual production app)