Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

536
Visualizações
I have an Error 429 with spotify api on single request

I am making a website that retrieves and displays my playlists, everything was working fine yesterday, this morning while I did not touch the code I have an error 429 every time I want to retrieve data on the api.

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've try with and without axios, that's not the problem.

I use this function in a React component class here :

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()
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

componentDidUpdate() is a lifecycle hook which runs the code within it every time the component re-renders.
A component in React updates whenever there is a change in it's state or it's props.
searchPlaylists() sets the state, which causes a re-render.
In other words, you have created an infinite loop where you update the state at every re-render, which causes another re-render, sending an API request every time.

For more in-depth information.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda