score:0

you should also create token and pass the token:

import sanityclient from '@sanity/client'

export const client = sanityclient({
  projectid: 'projectid',
  dataset: 'production',
  apiversion: '2021-03-25',
  token: 'click api tab and add new token',
  usecdn: false,
})

score:1

you can specify an api version when you configure your client:

import sanityclient from "@sanity/client";

export default sanityclient({
  projectid: "myprojectid",
  dataset: "production",
  usecdn: true,
  apiversion: "2022-02-03"
});

it's best to hard code your api version to the date you implement it. that way, it's guaranteed to work as you expect. if you were to use a javascript date to always return whatever today is, a breaking change could be put in place that causes the client to no longer work. there are a few more details in the documentation here.


Related Query

More Query from same tag