Estoy usando la cordura, también si necesita más información se la proporcionaré lo antes posible. Cuando voy a http://localhost:3000/api/getComments me escribe ese error:
ClientError: no se puede analizar el valor de "$tweetId=undefined". Por favor cita valores de cadena.
buscarComentarios.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 }obtenerComentarios.ts
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) }