-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.js
26 lines (21 loc) · 1004 Bytes
/
model.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
const apiKey = '7d94d40ee173cf65d6901779566190dc';
const apiUrl = 'https://api.themoviedb.org/3/';
async function fetchGenres() {
const response = await fetch(`${apiUrl}genre/movie/list?api_key=${apiKey}&language=en-US`);
return response.json();
}
async function fetchRecommendations(genreId) {
const response = await fetch(`${apiUrl}discover/movie?api_key=${apiKey}&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=1&with_genres=${genreId}`);
return response.json();
}
async function fetchMovieDetails(movieId) {
const response = await fetch(`${apiUrl}movie/${movieId}?api_key=${apiKey}&language=en-US&append_to_response=videos,credits,images`);
return response.json();
}
async function fetchPopularMovies() {
const response = await fetch(`${apiUrl}movie/popular?api_key=${apiKey}&language=en-US&page=1`);
return response.json();
}
document.getElementById('back-button').addEventListener('click', () => {
window.location.href = 'index.html';
});