Last active
February 17, 2019 12:16
-
-
Save DominicGBauer/e0b08ef5c39c68f199eae069d41b9122 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
// Create a KEY variable for the NASA API key you received earlier | |
// Make sure it's in quotations | |
const KEY = 'YOUR KEY' | |
// Create a nasa variable that we will use to perform our API request | |
// Axios is going to create a url for us that conforms to NASA's | |
// specifications | |
let nasa = axios.create({ | |
// baseURL is the url we saw ealier to access the APOD data | |
baseURL: 'https://api.nasa.gov/planetary/apod', | |
// params are the query parameters we can set | |
// I am chosing the date of 10 February 2019 (when I wrote this blog) | |
// I chose HD to be true (cause why not :)?) | |
// Finally the api_key is simply the key we got from NASA | |
params: { | |
date: '2019-02-10', // Don't forget the quotations | |
hd: true, | |
api_key: KEY | |
} | |
// Essentially this will create a url that looks like this | |
// https://api.nasa.gov/planetary/apod?date=2019-02-10&hd=true&api_key=KEY | |
}) | |
class App extends React.Component { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment