Missing image in the response

Hi, I’ve been working with Strapi for two days and am trying to get my coverImgae from my arikels. I get the remaining parameters with the following code, only the image is missing.


const BASE_URL = 'http://localhost:1337/api';

const API_KEY = '';

const axiosInstance = axios.create({
    baseURL: BASE_URL,
    headers: {
      'Authorization': `Bearer ${API_KEY}`
    }
  });
  
  const getPost = () => {
    console.log(axiosInstance.get('/artikels?populate=*'));
    return axiosInstance.get('artikels');
  };

  getPost()
  .then(response => {
    console.log(response.data); 
  })
  .catch(error => {
    console.error('Error:', error);
  });
  
  export default { getPost };

<i>This topic has been created from a Discord post (1224998902692970568) to give it more visibility.
It will be on Read-Only mode here.
<a href="https://discord.com/channels/811989166782021633/1224998902692970568/1224998902692970568">Join the conversation on Discord</a></i>

Does anyone know what that could be?

Is your image on 1 level deep relation? Are you using components?
The documentation says:

populate=*

Populate everything, 1 level deep, including media fields, relations, components, and dynamic zones

Maybe you need to use the populate several levels deep to set the images data on your response.

Take a look on documentation:

Hi, first of all thank you for the answer. No, I don’t use components. How can I see if the image is 1 level deep?

Look to y field “proof”.

My request http://localhost:1337/api/transactions?populate=* works well.

{
  "data": [
    {
      "id": 1,
      "attributes": {
        "starts_at": "2024-03-01",
        "ends_at": "2024-03-31",
        "createdAt": "2024-03-17T11:04:28.085Z",
        "updatedAt": "2024-04-03T13:58:33.706Z",
        "total": 0,
        "platform_total": 0,
        "user_total": 0,
        "proof": {
          "data": {
            "id": 4,
            "attributes": {
              "name": "Comprovante de Contratação de Cambio - Itau.pdf",
              "alternativeText": null,
              "caption": null,
              "width": null,
              "height": null,
              "formats": null,
              "hash": "Comprovante_de_Contratacao_de_Cambio_Itau_87bf02986f",
              "ext": ".pdf",
              "mime": "application/pdf",
              "size": 72.35,
              "url": "/uploads/Comprovante_de_Contratacao_de_Cambio_Itau_87bf02986f.pdf",
              "previewUrl": null,
              "provider": "local",
              "provider_metadata": null,
              "createdAt": "2023-11-17T22:53:14.304Z",
              "updatedAt": "2023-11-17T22:53:14.304Z"
            }
          }
        }
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

Okay, it actually looks the same, I’ll test something again and then report back here

Have you tried this with my code? I still don’t get an image back.

your example is not working due to not having the populate deep plugin (removed from plugin store) - you need to use the query string params to get the response you need without populate deep

Unfortunately I haven’t been here that long, could you explain this to me in more detail?

Can you show me an example of this?

Read this - Interactive Query Builder | Strapi Documentation

you need to use the qs library query string syntax to access content in your api

Thank you very much, it finally works now. I’m just lost, it gets the image but doesn’t display it correctly. Here is my css code

       rounded-2xl object-cover w-full h-full"> ```

I imagine your strapi instance is locally running at localhost:1337 and your next.js or whatever project is probably on port 3000 or something.

In which case, going to relative path on frontend to get an image will fail, you need the relative path to be that of your strapi instance.
Try amend the output path to have your local strapi url before the path for the image.

Hi, thank you very much. That worked. I now have another question, I’m trying to add an author to my articles, but I always get null for the author. Here my code: