I am using sanity, also if you need more information I will provide it as soon as possible. When I go to http://localhost:3000/api/getComments it writes me that error:
ClientError: Unable to parse value of "$tweetId=undefined". Please quote string values.
fetchComments.ts
import { Comment } from "../typings"
export const fetchComments = async (tweetId: string) => {
const res = await fetch(`/api/getComments?tweetId=${tweetId}`)
const comments: Comment[] = await res.json()
return comments
}```
getComments.ts
```tsx
import type { NextApiRequest, NextApiResponse } from "next";
import { groq } from "next-sanity";
import { sanityClient } from "../../sanitytwitter/sanity";
import { Comment } from "../../typings";
const commentQuery = groq`
*[_type == "comment" && references(*[_type == 'tweet' && _id == $tweetId]._id )]
{
_id,
...
} | order(_createdAt desc)
`
type Data = Comment[]
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
const { tweetId } = req.query;
const comments: Comment[] = await sanityClient.fetch(commentQuery, {
tweetId,
})
res.status(200).json(comments)
}```