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
19 lines (18 loc) · 699 Bytes
/
app.js
File metadata and controls
19 lines (18 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"use strict";
const GIPHY_URL = "https://api.giphy.com/v1/gifs/translate";
const GIPHY_KEY = "aYUJQCh0aRXvs7L8MZv8wHyoscMe7hAv";
let feedbackEle = document.querySelector("#feedback");
let searchInput = document.querySelector("#searchWord");
let searchBtn = document.querySelector("#submitSearch");
let gifEle = document.querySelector("#imageContainer > img");
searchBtn.addEventListener("click", (event) => {
fetch(`${GIPHY_URL}?api_key=${GIPHY_KEY}&s=${searchInput.value}`)
.then((res) => res.json())
.then((body) => {
gifEle.src = body.data.images.original.url;
})
.catch((err) => {
console.error(err);
feedbackEle.textContent = err.message;
});
});