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

85
Visualizações
How to prevent multiple Multiple Api calls

I am using a library video js with react. For getting the watch time of a video. I am getting the watch time properly and Api is working fine but the issue is when I move to the next video or I change the page while watching video, the Api is called multiple times. I want it to make a request only one time. I am using the following code.

 useEffect(()=>{

        const videoElement = videoRef.current;

      const player = playerRef.current = videojs(videoElement, options, () => {
                 console.log(player?.currentTime())
    
                player.on("timeupdate", function () 
                     player.on('dispose', (e) => {

                           console.log(e)
                           e.preventDefault()
dispatch(getWatchTime({userId:user?._id,videoId:watch?._id,watchTime:player.currentTime()}))
                
     })
                
    });
   })
      },[])

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