forked from benrbryant/JavaScript_APIs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
24 lines (22 loc) · 736 Bytes
/
app.js
File metadata and controls
24 lines (22 loc) · 736 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
console.log("Hello World!\n==========\n");
let searchBtn = document.getElementById("submitSearch");
let searchInput = document.getElementById("searchWord");
let feedbackEle = document.getElementById("feedback");
let img = document.querySelector("img");
searchBtn.addEventListener("click", () => {
fetch(
"https://api.giphy.com/v1/gifs/translate?api_key=54f0MhTKuI2nxwD9nhEvN4ifNwephcpz&s=" +
searchInput.value,
{ mode: "cors" }
)
.then((response) => response.json())
.then((res) => {
feedbackEle.textContent = "";
img.src = res.data.images.original.url;
searchInput.value = "";
})
.catch((err) => {
console.error(err);
feedbackEle.textContent = err.message;
});
});