The node.js way to deal with the above would look a bit more like this: function processData (callback) { fetchData(function (err, data) { if (err) { console.log(An error has occured. Abort everything!); callback(err); } data += 1; callback(data); }); }. At first glance, it may look unnecessarily complicated, but callbacks are the foundation of Node.js.