Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

86
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!