Reputation: 19
I have an app in flask but in my main.js
file I can't import an array from a .txt
file.
It's better to create a file like start.js
let fs = require("fs")
let readFileLines = filename =>
fs
.readFileSync(filename)
.toString('UTF8')
let arr = readFileLines('File.txt');
console.log(arr)
and prompt the command: node start.js
logs the arr
correctly while in my main.js
function myFunction() {
let fs = require("fs")
let readFileLines = filename =>
fs
.readFileSync(filename)
.toString('UTF8')
let arr = readFileLines('File.txt');
return arr
}
text: myFunction(),
it doesn't return the arr . I need it to load data into my plotly and if I try to do this test function it goes well
function myFunctionTest() {
arr = ["1","2"];
return arr
}
Upvotes: 0
Views: 68