Im kind of new to JavaScript and I wanted to open a text file, read from it to an object, then close it.
I made an object like this:
const users = {
    data: new Array()
} 
And after this I've tried, to push the thisUser object to the data list of the users, but it won't do it.
openFile() {
    const fs = require('fs')
    fs.readFile("some.txt", "utf-8", function(err, data) {
    
        if (err) { 
            throw err;
        }
        data = data.toString().split("\r\n")
        for (var i = 0; i < data.length; i++) {
            
            const line = data[i].split(";");
            var thisUser = {
                email:line[0],
                passw:line[1]
            }
            users.data.push(thisUser);
            console.log(line[0], line[1]);
        }
    })
}
openFile()
console.log(users);
I'm really stuck here and I couldn't find a solution for this.
I've tried to push it simply to an Array, but it doesn't work either. How could I do it, or what's seems to be the problem here?
