()
| 4 | getJoke(); |
| 5 | |
| 6 | function getJoke() { |
| 7 | fetch('https://icanhazdadjoke.com/', { |
| 8 | headers: { |
| 9 | 'Accept': 'application/json' |
| 10 | } |
| 11 | }).then(function(response) { |
| 12 | return response.json(); |
| 13 | }).then(function(data) { |
| 14 | const joke = data.joke; |
| 15 | jokeText.innerText = joke; |
| 16 | }); |
| 17 | } |
| 18 | |
| 19 | newJokeBtn.onclick = () => getJoke() |