Skip to content

Commit 86a5992

Browse files
author
longjichen1
committedSep 11, 2022
no more multiple calls
1 parent be03c3a commit 86a5992

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed
 

‎components/Modal.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ function Modal({
7474
await recMany();
7575
};
7676

77-
const recResult = result();
78-
7977
function reset() {
8078
setTitle({});
8179
onClose();
@@ -130,7 +128,7 @@ function Modal({
130128
<div className="flex flex-col justify-center bg-[#ebf0f7]">
131129
<h1 className="mt-2 text-lg font-bold text-center">Recommendations</h1>
132130
{/* //button */}
133-
<Recs results={recResult} />
131+
<Recs results={result} />
134132
</div>
135133
</div>
136134
);

‎components/Recs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function Recs({ results }) {
66
const [movieArray, setMovieArray] = useState([]);
77

88
useEffect(() => {
9-
handleResults(results, setMovieArray);
9+
handleResults(results(), setMovieArray);
1010
}, []);
1111

1212
return (

‎pages/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ export default function Home({ results }) {
8787
}
8888

8989
export async function getServerSideProps() {
90-
let allMovies = await fetch("http://localhost:8080/all-movies").then((res) =>
91-
res.json()
90+
let allMovies = await fetch("http://localhost:8080/all-movies").then(
91+
(res) => {
92+
if (!res.ok) return [];
93+
return res.json();
94+
}
9295
);
9396

9497
return {

0 commit comments

Comments
 (0)
Please sign in to comment.