fs in angular 1

fs in angular

import * as fs from 'fs';
import * as path from 'path';
fs.readFile(path.join(__dirname, '../../client/index.html'), 'utf8', (error, data) => {
        // ...

Here is what the above code is Doing:
1. We’re importing the fs module, which is the Node.js file system module.
2. We’re importing the path module, which is the Node.js path module.
3. We’re calling the readFile method on the fs module, which takes two arguments:
a. The path to the file we want to read.
b. The encoding of the file.
4. We’re passing in a callback function to the readFile method.
a. The callback function takes two arguments:
i. An error object.
ii. The data from the file.

Similar Posts