Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function fetchMovieByQuery(inputValue, page) {
- return async (dispatch) => {
- return response = await fetch(
- `${MOVIEDB_BASE_URL}/search/movie?api_key=${MOVIEDB_API_KEY}&query=${inputValue}&page=${page}`,
- );
- };
- }
- export function fetchMovieByGenre(genre, page) {
- return async (dispatch) => {
- return response = await fetch(
- `${MOVIEDB_BASE_URL}/discover/movie?api_key=${MOVIEDB_API_KEY}&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&page=${page}&with_genres=${genreId}`,
- );
- };
- }
- export function fetchMovieByPopular(page) {
- return async (dispatch) => {
- response = await fetch(
- `${MOVIEDB_BASE_URL}/movie/now_playing?api_key=${MOVIEDB_API_KEY}&page=${page}`,
- );
- };
- }
- export function handleFetchResponse(response) {
- return async (dispatch) => {
- const res = handleErrors(response);
- const json = await res.json();
- const results = json.results;
- console.log(json);
- console.log(json.results);
- const pageCount = json.total_pages;
- dispatch(fetchPageCount(pageCount));
- dispatch(fetchMoviesSuccess(results));
- return json.results;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement