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
16 lines (13 loc) · 630 Bytes
/
app.js
File metadata and controls
16 lines (13 loc) · 630 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
const button = document.getElementById("btn");
const image = document.getElementById("imageContainer");
const gifSearch = document.getElementById("gifSearch");
const getGif = () => {
fetch('https://api.giphy.com/v1/gifs/translate?api_key=a0H5W3rhVWGopepLbarAmisr0qvv9hAw&s='+gifSearch.value, {
mode: 'cors',
}).then(res => res.json())
.then(res => {console.log(res); image.src = res.data.images.original.url})
.catch(error => console.log(error))};
button.addEventListener('click', getGif);