Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec5d7fd

Browse files
authored
Update MAKEME.md
1 parent 24bce9e commit ec5d7fd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Week6/MAKEME.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,27 @@ How to hand in your homework:
4343
• Your hyf-javascript2/week3 should now contain an index.html, main.css and a script.js file (and the images folder)
4444
• Place the link to your repository folder in Trello.
4545
```
46+
47+
48+
## Homework for JavaScript
49+
Make a website that fetches (= to get) data asynchronously.
50+
51+
1) Create a new website with external js file
52+
53+
2) Add a button (e.g. 'click me') that when clicked `console.logs` 'you clicked me!'
54+
55+
3) Create a function that fetches from [this weather API](https://openweathermap.org/current). For example from [this page] (http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1). For help on this check this [SO post](https://stackoverflow.com/questions/247483/http-get-request-in-javascript)
56+
57+
4) Display the data that you get from the weather API on your web page.
58+
59+
5) Now link the two together: When you click the button -> get the data from the weather API and display it on your website
60+
61+
6) BONUS: if you look at this:
62+
63+
```
64+
http://samples.openweathermap.org/data/2.5/weather?q=London,uk&appid=b1b15e88fa797225412429c1c50c122a1
65+
```
66+
67+
you can see `?q=London,uk` in the URL. These are called "query parameters" and let us specify in detail what we want from the API. Play around with this. For example you can make two buttons that either get data for London or Amsterdam. Or go even more crazy and make users type in a search box 'amsterdam' and then send that to the API by changing the location.
68+
69+

0 commit comments

Comments
 (0)