Skip to content

Commit

Permalink
Fix server action error
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanMejia77 committed Mar 15, 2024
1 parent 2babcc6 commit 28437b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/actions/reviews.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use server";

export const getReviews = async () => {
const response = await fetch("http://localhost:3005/reviews");
const { data } = await response.json();
return data;
try {
const response = await fetch("http://localhost:3005/reviews");
const { data } = await response.json();
return data;
} catch (_) {
return [];
}
};
5 changes: 4 additions & 1 deletion src/components/Reviews/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Review } from "@/types";
import { ReviewsMarquee } from "./ReviewsMarquee";
import { getReviews } from "@/actions/reviews";

export const Reviews = async () => {
const reviews = await getReviews();
const reviews: Review[] = await getReviews();

if(!reviews.length) return null

return (
<section
Expand Down

0 comments on commit 28437b3

Please sign in to comment.