Reads the current directory synchronously
const fs = require('fs')

// With Sync function
let files = fs.readdirSync('./')
console.log(files)
Reads the current directory asynchronously
const fs = require('fs')

// With Async function
fs.readdir('./', function(err, files){
    if (err) {
        console.log('Error', err)
    } else {
        console.log(files)
    }
})
by Valeri Tandilashvili
2 years ago
Node
Node.js Tutorial for Beginners - 1 Hour
0
Pro tip: use ```triple backticks around text``` to write in code fences