Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

Which of these correctly reads a file asynchronously using promises?

  1. A fs.readFileSync(path)
  2. B await fs.promises.readFile(path)
  3. C fs.read(path)
  4. D require('fs').get(path)
Answer

await fs.promises.readFile(path)

fs.promises provides the promise-based API. It should be used for anything on a request path so the event loop stays free.

All NodeJS MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as