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

174
Vistas
how to get the value out of reader.load function

i have a function getHash in which i am passing the file to get the hash.

function getHash(data) {
console.log(data);
const [file] = data;
console.log(file);
const reader = new FileReader();
let dataHash ;
reader.onload = () => {dataHash=md5(reader.result),console.log(dataHash)};
if (file) {
    reader.readAsText(file);
}
console.log(dataHash);
return dataHash;

}

then i am calling it inside another function but how will i get the value of dataHash in the function in which i am calling it

FIRMWARE.uploadFiles = (body, index) => {
body.size += body.data[index].size;
let bodyData = body.data;
console.log(typeof (bodyData));
console.log(bodyData[1]);
let fileHash = [];
let hash = '';
getHash(bodyData);
// console.log(hash);
// fileHash.push(hash);

if (bodyData.length = 2) {
    const dt = new DataTransfer();
    dt.items.add(bodyData[1]);
    getHash(dt.files);
}
//console.log(dataHash);
body['fileHash'] = fileHash;

i want the value of hash to be returned by getHash function in the below function

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