cinema/movie.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-04-02 12:00:24 +02:00
function getMovieUtils() {
let currentMovieList;
let currentFilter = 1337;
let url = "https://api.themoviedb.org/3/";
let api_key = "6c6af57a7dd83a4c720a50bb8f21853c";
let utils = {
getTopRatedMovies,
getPopularMovies,
getComingSoonMovies,
getNewMovies,
getCurrentFilter
};
function getTopRatedMovies(page_index) {
return fetch(url + "movie/top_rated?api_key=" + api_key + "&page=" + page_index)
.then(response => response.json())
.then(data => data);
}
function getPopularMovies(page_index) {
return fetch(url + "movie/popular?api_key=" + api_key + "&page=" + page_index)
.then(response => response.json())
.then(data => data);
}
function getComingSoonMovies(page_index) {
return fetch(url + "movie/upcoming?api_key=" + api_key + "&page=" + page_index)
.then(response => response.json())
.then(data => data);
}
function getNewMovies(page_index) {
return fetch(url + "movie/now_playing?api_key=" + api_key + "&page=" + page_index)
.then(response => response.json())
.then(data => data);
}
function getCurrentFilter() {
return localStorage.getItem("currfilter");
}
return utils;
}