
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe error you're seeing is actually about how you're executing the query, not the GROQ syntax itself! The httpUnknownQueryStringParameters error means you're accidentally passing slug.current as an HTTP query parameter instead of as a proper GROQ parameter.
The issue is in your query string - you're using JavaScript template literals (${slug}) which is trying to interpolate the value directly into the query string. When this gets sent to Sanity's API, it's being interpreted incorrectly.
Your current query:
*[_type == "post" && slug.current == "${slug}"]This is trying to do string interpolation, which doesn't work properly with GROQ and can cause the API to misinterpret parts of your query as HTTP parameters.
Use GROQ parameters instead - they're safer, cleaner, and the recommended approach according to the GROQ parameters documentation:
const query = '*[_type == "post" && slug.current == $slug][0]'
const params = { slug: slug }
const result = await sanityClient.fetch(query, params)Notice:
$slug in the query (with the $ prefix)params object as the second argument to fetch()The Vision tool works because you're typing the query directly with the actual value, but when using the client programmatically, you need to use the parameter syntax. This is the same reason your simple *[_type == "post"] query works - it doesn't have any dynamic values that could be misinterpreted!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store