Go Behind the Experience to see how Tecovas brings the West to life with Sanity 🤠 July 18th

Query in initialValue returns empty array, but works in Vision. Dataset was set to PRIVATE, changed to PUBLIC and it works.

6 replies
Last updated: Mar 11, 2024
Hey all, yesterday my query in initialValue worked fine, today it returns an empty array. Running the same query in Vision returns data just fine. Any ideas what that could be?

initialValue: async () => {
    const categories = await client.fetch(`*[_type == "blog-category"]`);

    return {
      order: categories.length,
Feb 29, 2024, 10:52 AM
Initial values only work on document creation. If this document already exists it won’t run.
Feb 29, 2024, 3:40 PM
for both new and existing documents, if I do
I see
Mar 1, 2024, 6:11 AM
user M
any ideas what this could be? so odd, it worked initially and then the next day just not
Mar 1, 2024, 10:57 AM
It looks like you’re querying a different document type in Vision.
Mar 1, 2024, 4:26 PM
In my screenshots I’m querying the same document type. Initial message I was querying a different document type but the issue is the same.
Mar 2, 2024, 6:48 AM
for anyone discovering this…. my dataset was set to PRIVATE. changed it to PUBLIC and it works
Mar 11, 2024, 6:15 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?