Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Typical node.js callback pattern
// include the filesystem module
var fs = require('fs');
// fs.readFile: read a file and all its contents,
// then call a callback function
fs.readFile('/some/file', function (err, contents) {
// if any error occurred, throw it
if (err) throw err;
// do something when no error occurred
/* something(); */
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment