I can not understand how async / await works . I understand this a bit, but I can't get it to work.
function loadMonoCounter() {
fs.readFileSync("monolitic.txt", "binary", async function(err, data) {
return await new Buffer( data);
});
}
module.exports.read = function() {
console.log(loadMonoCounter());
};
I know I can use readFileSync , but if so, I know that I will never understand async / wait, and I just forget the problem.
Purpose: call loadMonoCounter () and return the contents of the file.
This file is incremented each time incrementMonoCounter () is called (every page load). The file contains the buffer dump in binary format and is stored on the SSD.
No, I am making a mistake, I get an error message or undefined in the console.
source
share