deleteJS
This commit is contained in:
parent
3988d3a323
commit
ab284de163
@ -1,37 +0,0 @@
|
||||
const jokeEl = document.getElementById('joke')
|
||||
const jokeBtn = document.getElementById('jokeBtn')
|
||||
|
||||
jokeBtn.addEventListener('click', generateJoke)
|
||||
|
||||
generateJoke()
|
||||
|
||||
// USING ASYNC/AWAIT
|
||||
async function generateJoke() {
|
||||
const config = {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
}
|
||||
|
||||
const res = await fetch('https://icanhazdadjoke.com', config)
|
||||
|
||||
const data = await res.json()
|
||||
|
||||
jokeEl.innerHTML = data.joke
|
||||
}
|
||||
|
||||
// USING .then()
|
||||
// function generateJoke() {
|
||||
// const config = {
|
||||
// headers: {
|
||||
// Accept: 'application/json',
|
||||
// },
|
||||
// }
|
||||
|
||||
// fetch('https://icanhazdadjoke.com', config)
|
||||
// .then((res) => res.json())
|
||||
// .then((data) => {
|
||||
// jokeEl.innerHTML = data.joke
|
||||
// })
|
||||
// }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user