I recently encountered an issue with my website where I am trying to retrieve and display my playlists. Everything was working fine yesterday, but this morning I started getting error 429 every time I tried to retrieve data from the api, even though I haven't made any changes to the code.
Here is a snippet of my code :
export const getUserPlaylist=async(params=null){
params={
params,
headers:{'Authorization': `Bearer ${AccessToken}`}
}
const response=await axios.get("https://api.spotify.com/v1/me/playlists", params)
return response.data
}
I have tried using axios and also without it, but the issue persists.
I am using this function in a React component class as shown below :
async searchPlaylists(){
if(!this.state.allPlaylists){
const response=await getUserPlaylist({limit:50})
this.setState({allPlaylists:response.items})
}
let playlists=[]
for(let i of this.state.allPlaylists){
if(i.name.indexOf(this.props.playlistName)===0){
playlists.push(new Playlist(i))
if(playlists.length===3) break
}
}
this.setState({playlists})
}
async componentDidMount(){
this.searchPlaylists()
}
async componentDidUpdate(){
this.searchPlaylists()
}