adrianhajdin / project_professional_portfolio

This is a code repository for the corresponding YouTube video. In this tutorial we are going to build and deploy a real time chat application. Covered topics: React.js, SCSS, Framer Motion, Sanity
https://jsmastery.pro
2.07k stars 496 forks source link

SanityClient issue #60

Open Raghxv11 opened 1 year ago

Raghxv11 commented 1 year ago

So I was getting an error in my client.js file that sanityClient is not exported from sanity/client. I figured that it was deprecated, so I used createClient instead of sanityClient:

`import { createClient } from '@sanity/client'; import { imageUrlBuilder } from '@sanity/image-url';

export const client = createClient({ projectId: process.env.REACT_APP_SANITY_PROJECT_ID, dataset: 'production', apiVersion: '2023-05-03', useCdn: true, token: process.env.REACT_APP_SANITY_TOKEN, });

const builder = imageUrlBuilder(client);

export const urlFor = (source) => builder.image(source);`

But now I am getting a TypeError: Object(...) is not a function And apparently its in node modules?

Screenshot (101)

What do I do?

tanbiralam commented 1 year ago

I am also facing the same issue. But Solve it. You have to change some modification. In vite.config.js you have to add this code:

`import { defineConfig } from 'vite' import react from '@vitejs/plugin-react'

import { config } from 'dotenv'; config();

// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], define: { 'process.env': process.env }

})`

This can fix the error