-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
61 lines (45 loc) · 1.79 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let api = '426f0157';
const button = document.querySelector('button');
const addbutton = document.querySelector('#add')
const text = document.querySelector('#text');
var boxoffice = document.querySelector('#boxoffice');
var awards = document.querySelector('#awards');
var director = document.querySelector('#director');
var writers = document.querySelector('#writers');
var yeard = document.querySelector('#year');
var title = document.querySelector('#title');
// http://www.omdbapi.com/?apikey=[426f0157]&
button.addEventListener('click', function(){
fetch(`https://www.omdbapi.com/?apikey=${api}&t=` + text.value)
.then(res => res.json())
.then(data => {
var money = data['BoxOffice']
var awar = data['Actors']
var dir = data['Director']
var writ = data['Writer']
var year = data['Year']
var titty = data['Title']
awards.innerHTML = `Cast: ${awar}`
director.innerHTML = `Director: ${dir}`
writers.innerHTML = `Story by: ${writ}`
yeard.innerHTML = `Release date: ${year}`
boxoffice.innerHTML= `Box Office: ${money}`;
console.log(data);
})
});
addbutton.addEventListener('click', function(){
fetch(`https://www.omdbapi.com/?apikey=${api}&t=` + text.value)
.then(res => res.json())
.then(data => {
var money = data['BoxOffice']
var awar = data['Actors']
var dir = data['Director']
var writ = data['Writer']
var year = data['Year']
var titty = data['Title']
const money1 = document.createElement('h3');
document.body.appendChild(money1)
money1.innerHTML = ` Title - ${titty}, Main Cast: ${awar}, Directed by: ${dir}, Story by: ${writ}, Release date: ${year}, Box Office: ${money}`;
console.log(data);
})
});