From 7bfb39e810f832e36a7181ebebf705a1d4c8415e Mon Sep 17 00:00:00 2001 From: Chris Phillips Date: Tue, 18 Sep 2018 10:33:26 +0100 Subject: [PATCH 1/7] First commit, inital Fetch functionality created --- index.html | 2 +- script.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 script.js diff --git a/index.html b/index.html index b1add34..e458674 100644 --- a/index.html +++ b/index.html @@ -43,7 +43,7 @@

- + diff --git a/script.js b/script.js new file mode 100644 index 0000000..78049ff --- /dev/null +++ b/script.js @@ -0,0 +1,37 @@ +console.log("hello World"); + +const generateApi = () => { + fetchContent(openWeatherApi); + +}; + + +function displayContent(body) { + console.log(body.weather[0].description); + const weatherDescription = body.weather[0].description; + const weatherURL = `https://api.unsplash.com/search/photos?page=1&query=${weatherDescription}&client_id=d1463f432cce4150640ff56ee13c1f94ec0b2993db4395bcb8913f34daeb0d48` +} + + + +const openWeatherApi = 'http://api.openweathermap.org/data/2.5/weather?q=london&APPID=a5f7c750d155ca20e98664c5fb5fe010'; +const unsplashApi = 'https://api.unsplash.com/search/photos?page=1&query=office&client_id=d1463f432cce4150640ff56ee13c1f94ec0b2993db4395bcb8913f34daeb0d48'; + + + +function fetchContent(url){ + // main news body fetch - button changeable + fetch(url) // by default fetch makes a GET request + .then(function(response) { + + return response.json(); + }) + .then(function(body){ + // parentNode.innerHTML = ""; + displayContent(body); + }); +} + + +generateApi(); +console.log(generateApi); \ No newline at end of file From b255f4f91a9a3a12476ec3583b8fa5a3404cd555 Mon Sep 17 00:00:00 2001 From: Tony Batty Date: Tue, 18 Sep 2018 11:36:27 +0100 Subject: [PATCH 2/7] displaying thumbnails --- index.html | 6 +++++- script.js | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index e458674..f67e526 100644 --- a/index.html +++ b/index.html @@ -32,7 +32,11 @@

-
+
+ + + +