Commit ab2a8d78 authored by Kim, Subin's avatar Kim, Subin
Browse files

SearchResult Pagination 필요없음 -> 관련 기능 삭제

parent 4b0f9909
......@@ -18,6 +18,7 @@ const MovieEdit = () => {
async function paginate(pageNum) {
try {
setError("")
const { TMDBmovies, totalPage } = (search.keyword !== '') ? await movieApi.search(search, pageNum) : await movieApi.getAllfromTM(pageNum)
setActivePage(pageNum)
setTotalPages(totalPage)
......
......@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import queryString from 'query-string'
import MovieCard from "./MovieCard/index.js"
import Pagination from "./Pagination.js";
import movieApi from '../apis/movie.api.js'
import catchErrors from '../utils/catchErrors.js'
......@@ -18,8 +19,8 @@ const SearchResult = () => {
async function findforKeyword() {
try {
setError("")
const { count, results } = await movieApi.search({ type: "home", keyword: title })
setResult([...results])
const res = await movieApi.search({ type: "home", keyword: title })
setResult(res)
} catch (error) {
catchErrors(error, setError)
}
......
......@@ -97,8 +97,6 @@ const getMovieById = async (req, res) => {
}
const getMovieList = async (req, res) => {
const { category } = req.params
// console.log(category)
try {
const { category } = req.params
const movieList = await Movie.findAll()
......@@ -178,15 +176,15 @@ const findonlyTitle = async (req, res) => {
try {
const { keyword } = req.query
const movieIds = []
const { count, rows } = await Movie.findAndCountAll({
const findAll = await Movie.findAll({
where: {
title: {
[Op.substring]: keyword
}
}
});
if (rows) {
rows.forEach(movie => movieIds.push(movie.movieId))
if (findAll) {
findAll.forEach(movie => movieIds.push(movie.movieId))
const elements = await Promise.all(
movieIds.map(async (movieId) => {
const movie = await axios.get(`https://api.themoviedb.org/3/movie/${movieId}?api_key=${process.env.TMDB_APP_KEY}&language=ko-KR`)
......@@ -200,8 +198,8 @@ const findonlyTitle = async (req, res) => {
return { ...movie.data, ticket_sales: cols.ticket_sales, vote_average: cols.vote_average, totalReservationRate: totalReservationRate[0] }
})
)
return res.json({ count: movieIds.length, results: elements })
} else return res.json({ count: count, results: rows })
return res.json(elements)
} else return res.json(findAll)
} catch (error) {
return res.status(500).send(error.message || "영화 검색 중 에러 발생");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment