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' const SearchResult = () => { const [result, setResult] = useState([]) const [error, setError] = useState("") const { search } = useLocation() const { title } = queryString.parse(search) useEffect(() => { findforKeyword() }, [title]) async function findforKeyword() { try { setError("") const res = await movieApi.search({ type: "home", keyword: title }) setResult(res) } catch (error) { catchErrors(error, setError) } } return (