This will be a two-module project. In it you will consume the NASA API to fetch the “Astronomy Photo Of The Day” or APOD. Once you fetch the data, you will build a few components that will render different pieces of data in your interface. After the second module (in the DAY_TWO_README.md file) you will re-style your app using one of the libraries you learn.
Read these instructions carefully. Understand exactly what is expected before starting this project.
Commit your code regularly and meaningfully. This helps both you and your team lead in case you ever need to return to old code for any number of reasons.
In this project you will build out a application to show the nasa photo of the day.
This project was put together using create-react-app (CRA). You will not need to install CRA in order to make this project work. Follow the steps below to setup the project with the proper dependencies.
yarn
or npm install
yarn start
or npm start
<firstName-lastName>
.
Implement the project on your newly created <firstName-lastName>
branch, committing changes regularly.<firstName-lastName>
.Follow these steps for completing your project.
Step 1 - Planning
Step 2 - File structure
Step 3 - Fetching the Data
App.js
(or where ever you wanted to fetch the data) add state for the data you’ll be getting from NASA.axios
..then()
make sure to console.log
the response so you can look at the shape of the data. 😃DEMO KEY rate limits:
Hourly Limit: 30 requests per IP address per hour
Daily Limit: 50 requests per IP address per day
Note: if the photo url is NOT a photo, you will need to learn how to display a video in a React app on your own, OR just fetch the APOD from a different date by adding this to the back of the API endpoint: &date=2012-03-14
Step 4 - Adding the Data to State
Step 5 - Display the Data Now is the time to build out your other components. Compose your UI, and then pass the data to your children components via props so you can render it on the DOM.
Cannot read property 'url' of undefined
. This means that the data you passed as props is undefined, when you were expecting it to be an object. You can fix this by simply adding something like this to any component that needs to read data from your state object:// Display a loading message while the data is fetching
if (!props.photoOfTheDay) return <h3>Loading...</h3>;
// Display your component as normal after the data has been fetched
return (
{* your normal JSX here *}
);
Do not attempt stretch problems until MVP has been reached and a final commit has been made.
date
? You can pass a different date in your url like this https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=2012-03-14
to get the APOD from a different date. Add a date dropdown that allows you to select a different date and see that APOD. This will be quite a bit of work, but it will be a fantastic exercise to go through a little more complicated logic and interaction in your app. This is also a very common type of interaction, so it would be good to try this out## Part II - Advanced Styling Techniques