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

178
Views
Prueba de velocidad xmlhttprequest

Buenas tardes. Dígame cómo puedo devolver el 'event. cargado' que luego lo envía al estado

 const startSpeedTestAsync = () => async (dispatch: Dispatch) => { const url = config.SPEED_TEST; dispatch(setLoadTest(true)); const startTime = new Date().getTime(); dispatch(startSpeedTest({ startTime, isShowInfo: false })); const endRequest = (data: unknown) => { const endTime = new Date().getTime(); dispatch(setEndTime(endTime)); dispatch(calcSpeed(data)); dispatch(stopSpeedTest({ isLoadTest: false, isShowInfo: true })); }; const sendHttpRequest = (metod: string, currenUrl: string) => { const promise: Promise<unknown> = new Promise((resolve) => { const xhr = new XMLHttpRequest(); xhr.timeout = 5000; xhr.onprogress = function (event) { console.log('loaded: ', event.loaded); return event.loaded; }; xhr.onreadystatechange = function () { // Only run if the request is complete if (xhr.readyState !== 4) return; resolve(xhr.onprogress); // resolve(xhr.onprogress); }; xhr.open(metod, currenUrl); xhr.send(); }); return promise;

};

 sendHttpRequest('GET', url) .then((response: any) => console.log(response)) .catch(endRequest); };

No puedo entender cómo procesar correctamente la solicitud de que todo resultó. Estoy tratando de implementar una solicitud de xmlhttprequest y devolver el tamaño del archivo descargado para luego calcular la velocidad de la conexión a Internet. El problema es que no sé cómo devolver esta talla.

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!