From 3950bc5798fde56f4e7ce51934aafc5aa54df005 Mon Sep 17 00:00:00 2001 From: behuFTP Date: Sun, 4 Feb 2018 10:53:35 +0100 Subject: [PATCH 1/2] Updated exercise --- Week6/code/exercises.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Week6/code/exercises.js b/Week6/code/exercises.js index ee6016d1..262ab516 100644 --- a/Week6/code/exercises.js +++ b/Week6/code/exercises.js @@ -49,17 +49,15 @@ function getAjaxData(url, callback) { 1. First get all spaceX launches. Using this api: https://api.spacexdata.com/v1/launches and the function i have created above. -2. Then filter the successes. +2. Take the first launch and set the innerhtml of a span to the rocket_name. -3. Take the first launch and set the innerhtml of a span to the rocket_name. - -4. Using the giphy api get a url of a gif with the query text of "success". It should have a rating above 4. +3. Using the giphy api get a url of a gif with the query text of "success". It should have a rating above 4. const api_key = '2FuF3E9nyFeXWt3aHIfkxtKTUGn73v0w'; const query = 'smile'; const giphyUrl = 'http://api.giphy.com/v1/gifs/search?api_key=' + api_key + '&q=' + query; -5. set the src of a img to the gif url (look for the images key in the gifs object). +4. set the src of a img to the gif url (look for the images key in the gifs object). */ @@ -71,9 +69,9 @@ const giphyUrl = 'http://api.giphy.com/v1/gifs/search?api_key=' + api_key + '&q= 1. Create an input element that takes a number from 1-6. -2. Get the number from the input value. +2. Get the number from the input value, when a button is clicked. -3. Create a ul and add list elements that contains the names of the astronauts from this api: http://api.open-notify.org/astros.json +3. Create a ul and add the number from the input of list elements, that contains the names of the astronauts from this api: http://api.open-notify.org/astros.json */ From 3a8498598c771cf91fc48b443505f99979520ac7 Mon Sep 17 00:00:00 2001 From: behuFTP Date: Sun, 4 Feb 2018 10:55:13 +0100 Subject: [PATCH 2/2] Updated code --- Week6/code/review.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Week6/code/review.js b/Week6/code/review.js index 096ed39c..ed6e0ddc 100644 --- a/Week6/code/review.js +++ b/Week6/code/review.js @@ -171,20 +171,19 @@ Lets try and use query strings to create get gifs from the giphy api that limits */ +const showGifs = function(gifs) { + console.log(gifs); + + // how would we now get astronauts? + getAjaxData(giphyUrl, getGifs); +} + function getGifs(gifSearchQuery) { const api_key = '2FuF3E9nyFeXWt3aHIfkxtKTUGn73v0w'; const query = gifSearchQuery; const giphyUrl = 'http://api.giphy.com/v1/gifs/search?api_key=' + api_key + '&q=' + query; - const getGifs = function(gifs) { - console.log(gifs); - - - // how would we now get astronauts? - getAjaxData(giphyUrl, getGifs); - } - - getAjaxData(giphyUrl, getGifs); + getAjaxData(giphyUrl, showGifs); } getGifs('smile');