I'm stuck trying to fetch comments for a specific post, currently fetching returns all the comments on the site. Olny need posts for the specific post id.
[slug].js
I'm using const { data: commentList, error } = useSWR(`/api/comments/`, fetcher);
and in my comments.js (api)
switch (req.method) {
// get all comments for specific event_id
case "GET":
const { data, error } = await supabase
.from("comments")
.select("*, user_id (username, avatar_url)")
.order("created_at", { ascending: false })
if (error) {
res.status(500).json({ error: error.message });
} else {
res.status(200).json(data);
}
break;```
I've tried adding .eq but it wont work.