"Every time a sanity check is performed, an empty array is returned

I currently have two posts published. Both my localhost and domain name are listed in Sanity's CORS settings, but I am consistently encountering an issue where Sanity returns an empty array. Below is the configuration of my Sanity Client:

export default SanityClient({
  projectId: "******",
  dataset: "production",
  useCdn: true,
  apiVersion: "2021-10-21",
})

Furthermore, here is how I am utilizing this setup in my NextJS within a getStaticProps function:

  const query = `*` // also attempted with `*[_type == "post"]`
  return client.fetch(query).then((posts) => {
    console.log("data => ", posts)
    return {
      props: { posts },
    }
  })

https://i.sstatic.net/OJEI9.png

Answer №1

I was able to solve the issue by changing the project's visibility from private to public. Just a heads up, it's actually a blog. https://i.sstatic.net/xXzBA.jpg

Answer №2

After encountering a recent error, one potential cause could be that the dataset being used is set to private. To address this issue, follow these steps:

  1. Switch your dataset to public.
  2. If you prefer to keep the dataset private, generate a new access token and integrate it into the SanityClient.

Instructions for Generating an Access Token

https://example.com/access-token-step1.png

https://example.com/access-token-step2.png

You can then include the newly created token in your SanityClient setup as shown below:

export default SanityClient({
  projectId: "******",
  dataset: "production",
  useCdn: true,
  apiVersion: "2021-10-21",
  token: "<your-sanity-io-token>"
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Crockford's method of replacing values with nested objects

/** Custom Supplant Method **/ String.prototype.customSupplant = function(obj) { return this.replace (/{([^{}]*)}/g, function (match, propPath) { var props = propPath.split('.'); var result = obj; f ...

Images, videos, and audios fail to load on Vercel

I created a quirky Vercel app that poses a 'yes or no' question: "Do you want to see my dog?" If the answer is yes, my dog will appear with a woof audio; if the answer is no, you'll get jumpscared. It was just done for fun, using simple HTML ...

Adjusting the demonstration of the d3 force-directed graph

Recently, I have started learning about javascript and D3.js, and I am eager to grasp their functionalities. My current focus is on experimenting with the force-directed graph example available at: http://bl.ocks.org/mbostock/4062045 My goal is to modify ...

Execute PHP script via hyperlink

Is there a way for me to have a small PHP script that only gets the current page URL and echoes it when a user clicks on a submit button? I'm struggling because there are no other form items on the page, making it difficult to trigger the script. I th ...

Having difficulty implementing a personalized color scheme for the mui component

Attempting to set the background color as midnightBlue but encountering an error: Error: Cannot read properties of undefined (reading '100') Upon reviewing the syntax, no errors were found. Perhaps this issue stems from a dependency problem? ...

Ways to customize decoration in Material UI TextField

Struggling to adjust the default 14px padding-left applied by startAdornment in order to make the adornment occupy half of the TextField. Having trouble styling the startAdornment overall. Attempts to style the div itself have been partially successful, b ...

Collecting generated Image URIs from JavaScript with SeleniumJS

I've been attempting to develop a Python script that can extract QR codes from WhatsApp web using Selenium. However, I'm facing difficulties with getting it to function properly. The QR image on WhatsApp web is a PNG generated through live JavaS ...

How can I retrieve the identifier in Socket.io?

Is there a way to retrieve the unique Id from the server using socket.io? I attempted using clients[socket.id] = socket; However, I encountered an error stating: connections property is deprecated. use getconnections() method Does anyone have any sugg ...

Angular has trouble displaying information across multiple HTML files

I have created an HTML file to display some data. The initial HTML file named disc-log.html looks like this: <div> <h2>Discs</h2> <jhi-alert></jhi-alert> <div class="container-fluid"> <div class=" ...

Add CSS styles directly into the shadow-root instead of the head tag | Vue.js and Webpack

Currently, I'm developing a widget that can be embedded on websites using Vue.js along with vue-custom-element. Everything was going well until I encountered an issue. The problem arises when trying to integrate a component (along with its CSS) from ...

"Instead of seeing the expected content, a blank page is showing

I've been searching for a solution to this problem without any luck. Any assistance would be greatly appreciated. Initially, I created a "tabs" default project which worked fine as a base. However, after making a few modifications, the screen ended u ...

Prevent scaling in CSS3DRenderer

For a detailed explanation of what I am attempting to achieve, please refer to my previous question here. In summary: My goal is to have HTML elements rotate in sync with OrbitControls to give the illusion that these elements are attached to a globe and m ...

Using JavaScript to control a dropdown list based on the selection of another dropdown

Hello, I am new to programming and a JavaScript beginner seeking help from you all. I have two dropdown lists and I am attempting to manipulate one based on the selection of the other using JavaScript. Both dropdown lists contain time in hours denoting st ...

Modifying app aesthetics on-the-fly in Angular

I am currently working on implementing various color schemes to customize our app, and I want Angular to dynamically apply one based on user preferences. In our scenario, the UI will be accessed by multiple clients, each with their own preferred color sch ...

Having trouble with clearInterval in my Angular code

After all files have finished running, the array this.currentlyRunning is emptied and its length becomes zero. if(numberOfFiles === 0) { clearInterval(this.repeat); } I conducted a test using console.log and found that even though ...

Guide on spinning a particle in three.js

I am encountering an issue with a particle that leaves a circle behind when rotated as an image. How can I eliminate this unwanted circle effect? Check out the code on this Fiddle: http://jsfiddle.net/zUvsp/137/ Here's the code snippet: var camera, ...

Using Angular 4 to transfer data from a dynamic modal to a component

Currently implementing material design, I have set up a dialogService for dynamically loading MdDialog. My goal is to create a search dialog with filters that, upon submission, directs the user to a search-results component route. However, I am struggling ...

Angular update row and save data to an array

When comparing the data of an edited row with the row just below it, I encounter a specific scenario. In a table containing 5 rows, as I edit records from top to bottom using the provided code snippet, I am able to store the values in an array. The most re ...

Using Angular Material for creating tabs with identical content

I am using material with angularjs and have encountered an issue with my two md-tabs. Both tabs have a similar DOM structure, but contain some unique content. Instead of duplicating the common DOM twice, I am looking for an alternative solution. Is it poss ...

What's preventing my Angular list from appearing?

I am currently developing an Angular project that integrates Web API and entity framework code first. One of the views in my project features a table at the bottom, which is supposed to load data from the database upon view loading. After setting breakpoin ...