I am trying to perform a very basic search query with Sanity CMS.
This is how the person
schema I've created looks like:
export default {
title: "Person",
name: "person",
type: "document",
fields: [
{
title: "Name",
name: "name",
type: "string",
}
]
}
I have entered two different Person data. And this is how I try to fetch the data:
const client = sanityClient({
projectId: 'siaj5ql4',
dataset: 'production',
useCdn: true
})
const query = '*[_type == "person"]'
client.fetch(query).then(person => {
console.log(person)
})
But I get an empty array like so in the console: []
There is no error or anything.
Any ideas on this simple task?
There are two common reasons for this:
Also note that the CDN can not be used with private datasets and/or access token.