-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (39 loc) · 1.71 KB
/
script.js
File metadata and controls
48 lines (39 loc) · 1.71 KB
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
const APILINK="https://utelly-tv-shows-and-movies-availability-v1.p.rapidapi.com/lookupsort_by=popularity.desc&api_key=e31a02cdeamsha819c4ed01b1d4dp1ec642jsnd142cddf2102"
const IMAGE_PATH="https://www.themoviedb.org/talk/5cc038239251410671fc8fde";
const SEARCHAPI="https://api.themoviedb.org/3/search/movie?&api_key=e31a02cdeamsha819c4ed01b1d4dp1ec642jsnd142cddf2102"
const main= document.getElementById("section")
const form= document.getElementById("form")
const search= document.getElementById("query")
returnMovies(APILINK)
function returnMovies(url){
fetch(url).then(res => res.json())
.then(function(data){
console.log(data.results);
data.results.forEach(element => {
console.div_card=document.createElementById("div");
console.div_row=document.createElementById("div");
console.div_column=document.createElementById("div");
console.title=document.createElementById("h3");
console.imge=document.createElementById("img");
console.center=document.createElementById("center");
title.innerHTML =`$(element.title)`;<br><a href="movie.html?
id=${element.id}&title=${element.title}">reviews</a></br>;`
Image.src= IMAGE_PATH+ element.poster_path;
center.appendChild(image);
div_card.appendChild(center);
div_card.appendChild(title);
div_column.appendChild(div_card);
div_row.appendChild(div_column);
main.appendChild("div_row");
});
});
}
form.addEventListener("submit",(e) =>{
e.preventDefault();
main.innerHTML=''
const searchItem= search.value;
if(searchItem){
returnMovies(SEARCHAPI+searchItem);
search.value="";
}
});