Difficulty: 3/10directory listing, asynchronous I/O, error handlingThe fs.readdir() method is used to read the contents of a directory. It returns an array of file and directory names present in the specified directory.javascriptCopyScenario Questions0-2 years experience1How would you use fs.readdir to get a list of all files in a given folder and then log each filename?2What will happen if you call fs.readdir on a path that doesn't exist? How would you handle that in code?2-5 years experience1You need to implement an endpoint that returns the names of all JSON files in a user‑provided directory, but you must ignore sub‑directories and handle large directories efficiently. Walk me through how you'd use fs.readdir and any additional steps.Follow-up QuestionsWhat edge cases would you test for when using fs.readdir?How would you handle permission errors in production code?Can you show a short snippet that uses the promise API?Suggest Improvement