sanity客户端说模块""c:/Users/USER/Documents/...""没有导出的成员"sanityClient"



我已经安装了npm i @sanity/client

还是不行

我在sanityjs中创建了export const sanityClient = createClient(config);

import type { NextApiRequest, NextApiResponse } from 'next'
import { sanityClient } from '../../sanity'
import { Tweet } from '../../typings'
import { groq } from 'next-sanity'
const feedQuery = groq`
*[_type == 'tweet']{
_id,
...
}| order(_createdAt desc)`
type Data = {
tweets: Tweet[]
}
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<Data>
) {
const tweets: Tweet[] = await sanityClient.fetch(feedQuery)
// console.log(tweets)
res.status(200).json({ tweets })
}

这是我尝试导入sanity client的地方。

我已经解决了

问题是我没有把sanity.js文件放在主外部文件夹,我把它放在sanity文件夹

最新更新