Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs readfile

const fs = require('fs');

fs.readFile('/Users/joe/test.txt', 'utf8' , (err, data) => {
  if (err) {
    console.error(err);
    return
  }
  console.log(data);
});
Comment

readfile nodejs

const fs = require('fs')

try {
  const data = fs.readFileSync('/Users/joe/test.txt', 'utf8')
  console.log(data)
} catch (err) {
  console.error(err)
}
Comment

fs.readfile

fs.readFile('filename', function read(err, data) {
    if (err) {
        throw err;
    }
    var content = data;
  
    console.log(content);  
   
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript break out of loop 
Javascript :: regex to check if text is in quotations 
Javascript :: Loop over all keys in the local storage 
Javascript :: javascript element edit text 
Javascript :: average function for javascript 
Javascript :: stop interval js 
Javascript :: app.post (req res) get data 
Javascript :: unary operator javascript 
Javascript :: jquery after 
Javascript :: map javascript index 
Javascript :: javascript array 
Javascript :: get format file in javascript 
Javascript :: jquery remove focus from all elements 
Javascript :: open bootstrap modal with javascript 
Javascript :: js array of objects get a specific key from all objects 
Javascript :: count json objects 
Javascript :: js to uppercase 
Javascript :: smooth scroll safari 
Javascript :: Sort big numbers from an array in javascript 
Javascript :: create empty array javascript 
Javascript :: js map array to dictionary 
Javascript :: search inside array with object mongodb 
Javascript :: how to change materil ui divider coloer 
Javascript :: jquery focus input end of text 
Javascript :: angular http loader 
Javascript :: chart js small bars too thin 
Javascript :: slice javascript string 
Javascript :: puppeteer mac m1 
Javascript :: js string reverse exception 
Javascript :: import img react in another file 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =