![]() |
VOOZH | about |
Error-First Callback in Node.js is a function which either returns an error object or any successful data returned by the function.
Below is the implementation of Error-First Callback:
Create a file with the name index.js. The file requires an fs module. We will be implementing an error-first callback function on methods of the fs module. fs module can be used in the program by using the below command:
const fs = require("fs");
The file can be executed by using the below command:
node index.js
We will be using fs.readFile() to show error-first callback function.
Example 1:
Output:
👁 ImageExample 2:
Output:
👁 Image