-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
19 lines (15 loc) · 686 Bytes
/
index.js
File metadata and controls
19 lines (15 loc) · 686 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$("#botao").click(function(evento) {
evento.preventDefault();
sendRequest ();
})
async function sendRequest() {
let apiKey = "51ddeMDvPaIvycTmT7hLu7WU16YuAUtg3dlHsxqO";
let inputData = $("#inputData").val();
let apiKeyData = await fetch (`https://api.nasa.gov/planetary/apod?api_key=${apiKey}&date=${inputData}`);
let data = await apiKeyData.json();
$('body').css('background-image', `url(${data.url})`);
$('body').css("background-repeat", "no-repeat");
$('body').css("background-size", "cover");
document.querySelector('.tituloPrincipal').innerText = data.title;
document.querySelector('#explicacao').innerText = data.explanation;
}