-
Notifications
You must be signed in to change notification settings - Fork 0
Description
What's the problem you're trying to solve?
Trying to render events into a favorites.ejs page when user clicks on the heart icon, I tried to do this by grabbing the image from the API, just like in apple-pies-places app but I am not sure why this is not working. I'd like to know if I am using the right approach or if there are other alternatives I can implement. Thanks in advance, I need an experienced set of eyes to look into this
Post any code you think might be relevant (one fenced block per file)
Here is the API snippet where I wanted to gran the image from, I also included the code from favorites.ejs
{
"events": [
{
"type": "mls",
"id": 6077353,
"datetime_utc": "2023-12-31T09:30:00",
"venue": {},
"datetime_tbd": true,
"performers": [
{
"type": "mls",
"name": "St. Louis CITY SC",
"image": "https://seatgeek.com/images/performers-landscape/st-louis-city-sc-3-7d3951/793870/51611/huge.jpg",
"id": 793870,
"images": {
"huge": "https://seatgeek.com/images/performers-landscape/st-louis-city-sc-3-7d3951/793870/51611/huge.jpg"
},
Here is the favorites.ejs code
<%- include('../partials/header') %>
<div class="row row-cols-1 row-cols-md-2 g-4">
<% likedEvents.forEach(function(e) { %>
<div class="col">
<div class="card custom-card">
<% if (e.performers && e.performers.length > 0) { %>
<!-- Attempting to pull image from API path events/performers[0].img -->
<img src="<%= likedEvent.performers[0].images.huge %>" class="card-img-top" alt="Event Image">
<% } else { %>
<!-- Display a default image or handle the case where no image is available -->
<img src="https://i.imgur.com/N4yxzZK.png" class="card-img-top1" alt="Default Image">
<% } %>
<div class="card-body">
<h5 class="card-title"><%= e.type %></h5>
</div>
</div>
</div>
<% }) %>
</div>
<%- include('../partials/footer') %>
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
I don't see an error, but the default picture shows up on favorites and not the picture form the API
What is your best guess as to the source of the problem?
I think my schema might be messed up but I don't think I am looking at this right
What things have you already tried to solve the problem?
I tried to use events.performers[0].image but that didn't work