Help Wizard

Step 1

NEXT STEP

Syntax for accessing cover images

Syntax for accessing cover images

Plan

Free/Premium

Country

 

Device

(iPhone 8, Samsung Galaxy 9, Macbook Pro late 2016)

Operating System

(iOS 10, Android Oreo, Windows 10,etc.)

 

My Question or Issue

Pretty new at JS, but I'm unable to access the URL to a track's image file. It seems to be a syntax issue but I ive tried every way but upside down and it still does not send me the link back.

This is what I have landed on at the moment , r is just controlling a loop for a table

 

 

 

 

- var image_id = [r.track.album].images[0].url

 

 

 

 

And here is my what i am accessing

 

 

 

 

app.get("/recent", async (req, res) => {
  const userInfo = await getData("/me");
  const recents = await getData("/me/player/recently-played");

  console.log(recents.items);
  
  res.render("recent", {
    user: userInfo,
    recents: recents.items
  });
});

 

 

 

 

This is what console.log puts out for each track in the recents array

 

 

 

 

 track: {
      album: [Object],
      artists: [Array],
      available_markets: [Array],
      disc_number: 1,
      duration_ms: 61333,
      explicit: false,
      external_ids: [Object],
      external_urls: [Object],
      href: 'https://api.spotify.com/v1/tracks/7JqXZgtuqIFwzREMFAJOOS',
      id: '7JqXZgtuqIFwzREMFAJOOS',
      is_local: false,
      name: 'Erykah’s Gun',
      popularity: 50,
      preview_url: 'https://p.scdn.co/mp3-preview/94173470666754f32131c8964da1bc2a54860ce3?cid=9d8af94533ce40bda08ac5760e77ff9c',
      track_number: 14,
      type: 'track',
      uri: 'spotify:track:7JqXZgtuqIFwzREMFAJOOS'
    },
    played_at: '2022-11-15T04:14:29.673Z',
    context: {
      external_urls: [Object],
      href: 'https://api.spotify.com/v1/playlists/37i9dQZF1EVHGWrwldPRtj',
      type: 'playlist',
      uri: 'spotify:playlist:37i9dQZF1EVHGWrwldPRtj'
    }
  },

 

 

 

 

Any help or tips would be appreciated, thank you!

Reply
0 Replies

Suggested posts