Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Render ALL playlist names via Spotify API

I am trying to render multiple playlists I have created however I can only get one playlist at a time to show. I'm wondering how I can change my code to render ALL playlists instead of one playlist.

  getMyPlaylists(){
    spotifyApi.getUserPlaylists()
      .then((response) => {
         this.setState({
           myPlaylists: {
              playlists: response.items[0].name, //displays first playlist only
           
        }
      });
    })
  }

render() {

    return (
        <div>
        My Playlists:  { this.state.myPlaylists.playlists } 
        </div>
);
  }
}

export default App;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You should change your getMyPlaylists function with this:

  getMyPlaylists(){
    spotifyApi.getUserPlaylists()
      .then((response) => {
         this.setState({
           myPlaylists: {
              playlists: response.items
           
        }
      });
    })
  }

and you should loop over items in render like this:

{this.state.myPlaylists.playlists.map((playlist) => {
  return (
     <div>
        {playlist.name}
      </div>
   )
 })}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!