This is an app that displays a new photo each day using a NASA API.
https://nasa-photo-of-the-day-three.now.sh/
I built this project for Lambda School.
This project has a minimal design with data from a NASA API displayed into a card that has a floating animation as if it's in space. It dynamically updates every day with the new image, date, and description.
function App() {
// set useState and pull in data from API
const [date, setDate] = useState();
const [title, setTitle] = useState();
const [url, setUrl] = useState();
const [explanation, setExplanation] = useState();
// axious request to the API
// grab specific data
useEffect (() => {
axios.get(`https://cors-anywhere.herokuapp.com/https://api.nasa.gov/planetary/apod?api_key=OYB9iH2UyhXcplnYm1eMwAi6CRMi30yyTEKOpd99`)
.then (response => {
console.log(response.data);
setDate(response.data.date);
setTitle(response.data.title);
setUrl(response.data.url);
setExplanation(response.data.explanation);
})
.catch(err => console.log(err));
}, []);
if (!url) return <Loading />;
return (
// Display component on page
<div className="App">
<p>
{/* {<Loading />} */}
<PicOfTheDay
date={date}
title={title}
url={url}
explanation={explanation}
/>
</p>
</div>
);
}
Clone to your local machine
https://github.com/ardissam0/nasa-photo-of-the-day.git
Setup
$ npm i
$ npm start
https://api.nasa.gov/planetary/apod?api_key=OYB9iH2UyhXcplnYm1eMwAi6CRMi30yyTEKOpd99
Reach out to me on social media if you have any questions!