title: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data') when display image in vue 3
body: <p>I am new to vue js but when i try to display image by id on page there is an error Uncaught (in promise) TypeError: Cannot read properties of undefined (read 'data')</p>
  <p><strong>EventDetail.vue</strong></p>
  <pre><code>&lt;img :src=&quot;require(`../../../e-vents api/public${event.cover.data.attributes.formats.medium.url}`)&quot; alt=&quot;#&quot;/&gt;
  
  data() {
          return {
              event: &quot;&quot;,
          };
      },
  
  mounted() {
          fetch(`http://localhost:1337/api/events/${this.id}?populate=*`)
              .then((res) =&gt; res.json())
              .then((data) =&gt; (this.event = data.data.attributes))
              .catch((err) =&gt; console.log(err));
  },
  </code></pre>
  <p>I managed to display other data by <code>{{ event.title }}</code> but this one is not showing</p>
  <p><a href="https://i.stack.imgur.com/YM3XG.jpg" rel="nofollow noreferrer">project structure</a></p>
  <p><strong>Json Data</strong></p>
  <pre><code>{
  &quot;data&quot;: {
      &quot;id&quot;: 2,
      &quot;attributes&quot;: {
          &quot;title&quot;: &quot;Concert&quot;,
          &quot;description&quot;: &quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus blandit consequat diam, quis tristique mi luctus tincidunt..&quot;,
          &quot;date&quot;: &quot;2022-04-02T12:00:00.000Z&quot;,
          &quot;duration&quot;: 4,
          &quot;price&quot;: &quot;Rp. 500.000&quot;,
          &quot;createdAt&quot;: &quot;2022-03-23T15:01:33.339Z&quot;,
          &quot;updatedAt&quot;: &quot;2022-03-26T15:40:29.023Z&quot;,
          &quot;publishedAt&quot;: &quot;2022-03-23T15:01:34.908Z&quot;,
          &quot;location&quot;: &quot;Jl. Pintu Satu Senayan, Gelora, Kecamatan Tanah Abang, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10270&quot;,
          &quot;maps&quot;: &quot;https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3966.3419031479493!2d106.79960821378528!3d-6.218564762636128!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x2e69f14d30079f01%3A0x2e74f2341fff266d!2sStadion%20Utama%20Gelora%20Bung%20Karno!5e0!3m2!1sid!2sid!4v1648308601225!5m2!1sid!2sid&quot;,
          &quot;cover&quot;: {
              &quot;data&quot;: {
                  &quot;id&quot;: 1,
                  &quot;attributes&quot;: {
                      &quot;name&quot;: &quot;concert.jpg&quot;,
                      &quot;alternativeText&quot;: &quot;concert&quot;,
                      &quot;caption&quot;: &quot;concert.jpg&quot;,
                      &quot;width&quot;: 1920,
                      &quot;height&quot;: 1280,
                      &quot;formats&quot;: {
                          &quot;thumbnail&quot;: {
                              &quot;name&quot;: &quot;thumbnail_concert.jpg&quot;,
                              &quot;hash&quot;: &quot;thumbnail_concert_a354ef139e&quot;,
                              &quot;ext&quot;: &quot;.jpg&quot;,
                              &quot;mime&quot;: &quot;image/jpeg&quot;,
                              &quot;path&quot;: null,
                              &quot;width&quot;: 234,
                              &quot;height&quot;: 156,
                              &quot;size&quot;: 5.15,
                              &quot;url&quot;: &quot;/uploads/thumbnail_concert_a354ef139e.jpg&quot;
                          },
                          &quot;large&quot;: {
                              &quot;name&quot;: &quot;large_concert.jpg&quot;,
                              &quot;hash&quot;: &quot;large_concert_a354ef139e&quot;,
                              &quot;ext&quot;: &quot;.jpg&quot;,
                              &quot;mime&quot;: &quot;image/jpeg&quot;,
                              &quot;path&quot;: null,
                              &quot;width&quot;: 1000,
                              &quot;height&quot;: 667,
                              &quot;size&quot;: 68.26,
                              &quot;url&quot;: &quot;/uploads/large_concert_a354ef139e.jpg&quot;
                          },
                          &quot;medium&quot;: {
                              &quot;name&quot;: &quot;medium_concert.jpg&quot;,
                              &quot;hash&quot;: &quot;medium_concert_a354ef139e&quot;,
                              &quot;ext&quot;: &quot;.jpg&quot;,
                              &quot;mime&quot;: &quot;image/jpeg&quot;,
                              &quot;path&quot;: null,
                              &quot;width&quot;: 750,
                              &quot;height&quot;: 500,
                              &quot;size&quot;: 37.81,
                              &quot;url&quot;: &quot;/uploads/medium_concert_a354ef139e.jpg&quot;
                          },
                          &quot;small&quot;: {
                              &quot;name&quot;: &quot;small_concert.jpg&quot;,
                              &quot;hash&quot;: &quot;small_concert_a354ef139e&quot;,
                              &quot;ext&quot;: &quot;.jpg&quot;,
                              &quot;mime&quot;: &quot;image/jpeg&quot;,
                              &quot;path&quot;: null,
                              &quot;width&quot;: 500,
                              &quot;height&quot;: 333,
                              &quot;size&quot;: 17.85,
                              &quot;url&quot;: &quot;/uploads/small_concert_a354ef139e.jpg&quot;
                          }
                      },
                      &quot;hash&quot;: &quot;concert_a354ef139e&quot;,
                      &quot;ext&quot;: &quot;.jpg&quot;,
                      &quot;mime&quot;: &quot;image/jpeg&quot;,
                      &quot;size&quot;: 281.82,
                      &quot;url&quot;: &quot;/uploads/concert_a354ef139e.jpg&quot;,
                      &quot;previewUrl&quot;: null,
                      &quot;provider&quot;: &quot;local&quot;,
                      &quot;provider_metadata&quot;: null,
                      &quot;createdAt&quot;: &quot;2022-03-25T08:53:49.295Z&quot;,
                      &quot;updatedAt&quot;: &quot;2022-03-25T08:53:49.295Z&quot;
                  }
              }
          }
      }
  },
  </code></pre>
  <p><a href="https://i.stack.imgur.com/nB7mj.jpg" rel="nofollow noreferrer">when console.log looks like this</a></p>