我在控制台中收到此警告,但无法清楚地理解文档。
warnings.js:16 不推荐使用 Sanity 客户端而不指定 API 版本。请参阅https://docs.sanity.io/help/js-client-api-version
我希望它始终拥有最新的 API 版本。这是我的连接的样子
import santiyClient from "@sanity/client";
export default santiyClient({
projectId: "myProjectID",
dataset: "production",
useCdn: true,
});
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,
})
从 'next-sanity' 导入 { createClient };
export const sanityClient = createClient({
projectId: process.env.NEXT_PUBLIC_SANITY_PROJECT_ID, // Use environment variable for project ID
dataset: process.env.NEXT_PUBLIC_SANITY_DATASET, // Use environment variable for dataset
apiVersion: process.env.NEXT_PUBLIC_SANITY_API_VERSION, // Use environment variable for API version
useCdn: false, // Set to false if statically generating pages
token: process.env.SANITY_API_TOKEN, // Use environment variable for API token
});