Estoy tratando de representar varias listas de reproducción que he creado, sin embargo, solo puedo obtener una lista de reproducción a la vez para mostrar. Me pregunto cómo puedo cambiar mi código para mostrar TODAS las listas de reproducción en lugar de una lista de reproducción.
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;Deberías cambiar tu función getMyPlaylists con esto:
getMyPlaylists(){ spotifyApi.getUserPlaylists() .then((response) => { this.setState({ myPlaylists: { playlists: response.items } }); }) }y debe recorrer los elementos en el renderizado de esta manera:
{this.state.myPlaylists.playlists.map((playlist) => { return ( <div> {playlist.name} </div> ) })}