Skip to content

A sample Blazor app that fetches the Nasa Astronomy Picture of the Day

License

Notifications You must be signed in to change notification settings

ncarandini/BlazorNasaImages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlazorNasaImages

A sample Blazor app that use the Open Data Nasa APIs to fetch images from the Nasa Astronomy Picture of the Day service.

Points of interest

  1. Simple dinamic page layout change with a one-way binding to a boolean field and two components:
@if (cardView)
{
    <ImageCards NasaImageInfoList="@nasaImageInfoList" />
}
else
{
    <ImageList NasaImageInfoList="@nasaImageInfoList" />
}
  1. Use of the Javascript interop to write on the browser console the error message object in case of error:
// FetchNasaImages.cshtml
...
catch (Exception ex)
{
    RegisteredFunction.Invoke<bool>("consoleLog", ex);
}
...
// Index.html (in wwwroot)
...
<script>
    // Register a Javascript function
    Blazor.registerFunction('consoleLog', (data) => {
        console.dir(data);
        return true;
    });
</script>

(from the example of Javascript interopt found in the Learn Blazor site).

Here's the result: image

ApiKey

The key used in the source is an anonymous one (DEMO_KEY). Beware that this anonymous key has big usage restrictions, please get your free apiKey at https://api.nasa.gov/index.html#apply-for-an-api-key

Screenshots

image

image

image

About

A sample Blazor app that fetches the Nasa Astronomy Picture of the Day

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published