JavaScript fs.readFile function
ajayprashar (1)

My name is Ajay and I am new to JavaScript. I have a question I was hoping you could help me with:

How do I access the function 'fs.readFile' from within node within

import fs from 'fs';

let ourStuff = fs.readFile('G:\DATA\git\ipromise\ipromise.txt','utf8', callback);

Thank you,

You are viewing a single comment. View All
Answered by eankeen (678) [earned 5 cycles]
View Answer
ajayprashar (1)

@eankeen In appreciation of your reply, I thought I would provide an update.

As far as error messages go I adjusted my simple code as follows:

const fs = require('fs');

let ourStuff = fs.readFile('G:\\DATA\\git\\ipromise\\ipromise.txt','utf8', (err, data) => {
		if (err) throw err; 
		// Converting Raw Buffer to text 
		// data using tostring function. 

It occurred to me that perhaps the backslashes were being misinterpreted as escape keys or escape sequences, so I doubled them up as I do in linux configuration files. This adjustment rid me of all the error messages. Partial success!!!

However, the code does seem to run locally using Node with good output, but it runs successfully with NO output on

Should I assume that this is a security related issue?