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

175
Visualizações
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 à 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