Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

84
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda