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

172
Views
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
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!