Node.js · Junior · Question 53 of 75
How do you append a line to a file using promises?
- 1
fs.append("log.txt", "line\n") - ✓Correct answer:
await appendFile("log.txt", "line\n")fromnode:fs/promises - 3
await writeFile("log.txt", "line\n")
Explanation
writeFile replaces the whole file by default. appendFile adds to the end and creates the file if it doesn't exist.