Callback Hell
Avoid the callback triangle of doom with three simple rules:
- keep your code shallow
- modularize
- handle every single error
example:
var fs = require('fs')
fs.readFile('/Does/not/exist', handleFile)
function handleFile (error, file) {
if (error) return console.error('Uhoh, there was an error', error)
// otherwise, continue on and use `file` in your code
}