Search code examples
javascriptreactjsreststrapi

Strapi v4 REST API :GET image


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?


Solution

  • I realized 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/{imageUrl}' url/image route