const sanityClient = require('@sanity/client')
const client = sanityClient({
projectId: 'PROJECT_ID',
dataset: 'production',
token: process.env.TOKEN
})
I'm passing parameters in netlify functions file to sanityClient. I get error sanityClient is not a function. I am using sanity and netlify with Next.js. Thanks
I made a research after I posted this question.Require is not working on netlify functions therefore add this to netlify.toml
[functions]
node_bundler = "esbuild"
This will allow to import modules to netlify function files. Then import:
import sanityClient from "@sanity/client";
const client = sanityClient({
projectId: 'PROJECT_ID',
dataset: 'production',
token: SANITY_TOKEN
})