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
23 lines (18 loc) · 694 Bytes
/
app.js
File metadata and controls
23 lines (18 loc) · 694 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict'
console.log("Hello World!\n==========\n");
// Exercise 1 Section
console.log("EXERCISE 1:\n==========\n");
let submitbtn = document.getElementById('submit');
submitbtn.addEventListener('click', () => {
let apiImage = document.getElementById('gif');
let userInput = document.getElementById("type-of-gif").value;
let apiKey = 'F3PJP0CSLafPf720AJMNpaqYSL3T4oAA';
fetch(`https://api.giphy.com/v1/gifs/translate?api_key=${apiKey}&s=${userInput}`, { mode: "cors" })
.then((res) => {return res.json()})
.then((response) => {
console.log(response);
apiImage.src = response.data.images.original.url;
}).catch((err) => {
console.log(err);
});
});