I'm actually fighting with Promises on js.
I have a function where I want to return a value.
How do I call the return value?
I searched various sources, but didn't get the hang of it.
Thankyou very much in advance!!!
class ReadFile{
constructor(){
this.fs = require('fs')
}
async readData(pathToFile){
const readStream = this.fs.createReadStream(pathToFile, 'utf-8');
readStream.on('data', (chunk) => {
return chunk;
})
}
}
const read = new ReadFile();
read.readData('./resources/src/index.html').then(console.log);