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

267
Views
Render all playlists via spotify API

I'm trying to get my code to display my spotify playlists when I press "My Playlists". Here is the error I recieve and I believe it's because the map function I provide is not an array.

Uncaught TypeError: this.state.myPlaylists.playlists.map is not a function

Here is my code.

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

        
      });
    })
  }

Here is my render loop function using map

{ this.state.loggedIn &&
    <Button color="primary" variant="contained" onClick={() => this.getMyPlaylists()}>
        My Playlists  </Button> }
    <div>
      {this.state.myPlaylists.playlists.map((playlist) => {
      return (
       <div>
        {playlist.name}
      </div>
      )
 })}
   </div>

How can I resolve this issue? Thanks stackoverflow community.

about 4 years ago · Juan Pablo Isaza
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!