Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

414
Views
ClientError: Unable to parse value of "$tweetId=undefined". Please quote string values

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

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)
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!