├── .DS_Store ├── js ├── .DS_Store └── main.js └── index.html /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeustache00/NASA-Picture-of-the-Day-/HEAD/.DS_Store -------------------------------------------------------------------------------- /js/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jeustache00/NASA-Picture-of-the-Day-/HEAD/js/.DS_Store -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |

NASA's Astronomy Picture of the Day!

9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /js/main.js: -------------------------------------------------------------------------------- 1 | // NASA Picture of the Day: 2 | // the user can enter the date and click a button 3 | // 1 event listener 4 | // get NASA api url 5 | // if the user enters an invalid date alert them which date ranges are suitable 6 | 7 | 8 | 9 | $("#getpic").on("click",function(){ 10 | var getValue = $("#enterdate").val(); 11 | console.log(getValue); 12 | var apiKey = "0000000000"; 13 | var apiURL = "https://api.nasa.gov/planetary/apod?date=" +getValue+ "&api_key="+apiKey; 14 | console.log(apiURL); 15 | $.ajax({ 16 | url: apiURL, 17 | 18 | // Work with the response 19 | success: function(response){ 20 | console.log(response); 21 | $("img").attr("src", response.url); 22 | }, 23 | error: function(response){ 24 | console.log(response); 25 | } 26 | 27 | }); 28 | 29 | 30 | }); 31 | --------------------------------------------------------------------------------