project_professional_portfolio icon indicating copy to clipboard operation
project_professional_portfolio copied to clipboard

Images in About Section doesn't show after connecting to Sanity.

Open samwpr opened this issue 2 years ago • 9 comments

Hi everyone, could I please ask for assistance with the following issue?

I am at this section of the youtube tutorial. Screenshot 2022-09-13 at 4 42 23 PM

Everything was working perfectly, but once I connected to Sanity, this website section doesn't show. Screenshot 2022-09-13 at 4 43 44 PM

I have tried the following but nothing seems to work:

  1. Checking that in my client.js I use 'projectId' and not 'projectID'
  2. Instead of using 'process.env.REACT_APP_SANITY_PROJECT_ID' use the actual project ID. When I use 'process.env.REACT_APP_SANITY_PROJECT_ID' it shows a blank page. When I use the actual project ID I can see the website but the about us section is missing.

While following the tutorial the only thing I did that differed from the video was at 1:48:20 of the video where after he created the .env file he reloaded the application via ctrl c I am on a mac so in my terminal I used man kill instead.

Please find my code below: .env Screenshot 2022-09-13 at 4 39 41 PM

client.js Screenshot 2022-09-13 at 4 40 54 PM

About.jsx Screenshot 2022-09-13 at 4 53 54 PM

samwpr avatar Sep 13 '22 08:09 samwpr

same here... seems like many things aren't working well like google cloud integration as well...

M-TorresDeveloper avatar Nov 01 '22 17:11 M-TorresDeveloper

I also have the same problem

Teegreat avatar Nov 06 '22 05:11 Teegreat

using async await instead of .then worked for me.

const fetchAbouts = async () => { const query = '*[_type == "abouts"]'; setAbouts(await client.fetch(query)); }

useEffect(() => { fetchAbouts(); }, []);

This code worked for me but I don't know the logic behind this, if anyone can explain it would be great. TIA

bond0887 avatar Nov 06 '22 05:11 bond0887

Didn't work for me. Let me see your full code pls

Teegreat avatar Nov 06 '22 06:11 Teegreat

using async await instead of .then worked for me.

const fetchAbouts = async () => { const query = '*[_type == "abouts"]'; setAbouts(await client.fetch(query)); }

useEffect(() => { fetchAbouts(); }, []);

This code worked for me but I don't know the logic behind this, if anyone can explain it would be great. TIA

Full code pls

Teegreat avatar Nov 06 '22 06:11 Teegreat

using async await instead of .then worked for me. const fetchAbouts = async () => { const query = '*[_type == "abouts"]'; setAbouts(await client.fetch(query)); } useEffect(() => { fetchAbouts(); }, []); This code worked for me but I don't know the logic behind this, if anyone can explain it would be great. TIA

Full code pls

https://github.com/bond0887/portfolio-frontend

bond0887 avatar Nov 06 '22 06:11 bond0887

using async await instead of .then worked for me. const fetchAbouts = async () => { const query = '*[_type == "abouts"]'; setAbouts(await client.fetch(query)); } useEffect(() => { fetchAbouts(); }, []); This code worked for me but I don't know the logic behind this, if anyone can explain it would be great. TIA

Full code pls

https://github.com/bond0887/portfolio-frontend

Thanks but still stuck

Teegreat avatar Nov 06 '22 09:11 Teegreat

Finally found the solution.

Go to Sanity Manage Project => Add CORS ORIGIN => Paste this: http://localhost:* => Select "allow credentials" => Save and you are good to go

Teegreat avatar Nov 06 '22 11:11 Teegreat

Finally found the solution.

Go to Sanity Manage Project => Add CORS ORIGIN => Paste this: http://localhost:* => Select "allow credentials" => Save and you are good to go

Did this work for anyone?

justmarvee102 avatar Jun 12 '24 14:06 justmarvee102