-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (22 loc) · 716 Bytes
/
script.js
File metadata and controls
27 lines (22 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var botao = document.getElementById("botao")
function gerarPiada() {
fetch("https://official-joke-api.appspot.com/random_joke")
.then(response => response.json())
.then(data => {
alert(`${data.setup}\n${data.punchline}`);
})
.catch(error => {
alert("Erro ao buscar piada: " + error);
});
}
var botao2 = document.getElementById("botao2")
function gerar() {
fetch("https://restcountries.com/v3.1/name/brasil")
.then(response => response.json())
.then(data => {
alert(`Nome: ${data[0].name.common}\nCapital: ${data[0].capital}\nPopulação: ${data[0].population}`);
})
.catch(error => {
alert("Erro ao buscar dados do país: " + error);
});
}