The Line
const cat = (f) =>
new Promise(resolve => Object.assign(new FileReader(), {onload(){resolve(this.result)}}).readAsText(f));
Usage
<input type="file" onchange="cat(files[0]).then(console.log)">
For further actions, you may consider blocking this person and/or reporting abuse
Need a better mental model for async/await?
Check out this classic DEV post on the subject.
Georgios Kampitakis -
sharathchandark -
sharathchandark -
Kaja Uvais -
Top comments (0)