Skip to content

Instantly share code, notes, and snippets.

@klovadis
Created April 29, 2012 09:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klovadis/2548942 to your computer and use it in GitHub Desktop.
Save klovadis/2548942 to your computer and use it in GitHub Desktop.
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