0

please I am working with the new strapi v4 and... In the old versions of strapi all I needed to do in order to get the image from my collection type was to get it like: <img src={config.baseURL + product?.productImg?.formats?.thumbnail?.url} /> but when I try to do the same now, it gives me the url address, but the response says

{"data":null,"error":{"status":404,"name":"NotFoundError","message":"Not Found","details":{}}}

Any help?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
insider
  • 181
  • 1
  • 12

2 Answers2

3

with strapi v4 u need to manually populate your rest api with images otherwise it's restricted due to security reasons :

localhost:1337/api/posts?populate=*

then you will get images on your endpoint

Nsamba Isaac
  • 357
  • 4
  • 14
2

I realised it. In my config file I had the baseURL as 'localhost:1337/api'. However for images, you must request without the '/api' so the request should be just 'localhost:1337' and then the image route.

ouflak
  • 2,458
  • 10
  • 44
  • 49
insider
  • 181
  • 1
  • 12