Skip to main content
Node.js Code Reorder Hard +35 XP

Async File Read

Arrange the async file reading pattern correctly.

Click lines in the correct order

Available lines4 left

Your order

Click lines above to build your solution.

Show answer and explanation

Answer: try { const data = await fs.promises.readFile('file.txt', 'utf8'); console.log(data); } catch(err) { console.error(err); }

Wrap in try/catch, await the async read, then use the data.

Hint: try wraps the await, catch handles errors.

What this challenge tests

Code Reorder in Node.js: async-await, fs.

Related challenges