Diop Nikuze
Diop Nikuze

Reputation: 41

Impossible to access(display) the image url from Strapi v4 with ReactJS

I have a problem with Strapi v4, I can not display the image from Strapi.

Here is the data structure in Strapi: json-data

I tried to access the image with this source code but in vain : code-source reactjs

I get this error : Uncaught TypeError: Cannot read properties of undefined (reading 'data')

Please help me, I am new to Strapi

Upvotes: 0

Views: 1212

Answers (2)

Diop Nikuze
Diop Nikuze

Reputation: 41

I found the solution.

From the new version of strapi ( Strapi v4), all I had to do was to make the get request populate so I could get access to the image :

 useEffect(() => {
    axios.get("http://localhost:1337/api/articles?populate=*").then((res) => {
      setPosts(res.data);
    });
  }, []);

Upvotes: 3

Eduard
Eduard

Reputation: 535

maybe you are pointing in the wrong url of photos, just try without apiURL, because your images url already deployed in cloudinary

Upvotes: 0

Related Questions