title: Undefined 'callback' with Async Waterfall / Node.js
body: <p>I am trying to get a waterfall working in Node.js using Async but I keep getting the error</p>
  
  <blockquote>
    <p>callback (null, articleDataSafe, req);
                                                                    ^
    TypeError: undefined is not a function</p>
  </blockquote>
  
  <p>The code is as follows</p>
  
  <pre><code>async.waterfall([
                          function sanitizeData (articleData, req, callback) {
  
                                  articleDataSafe = sanitizeArticle(articleData);
                                  console.log('s1');
                                  callback (null, articleDataSafe, req);
  
                          },
  
                          function _validateData (articleDataSafe, req, callback) {
  
                                 var errors = validateArticle(articleData);
                                 var err = null;
                                 if(errors.length &gt; 0){
                                      // return error messages back to the browser
                                      err = JSON.stringify({'error': errors, "message": "fail"});
                                   };
                                  console.log('s2');
  
                                 callback (err, articleDataSafe, req);
  
                          },
  
                          function _saveArticle (articleDataSafe, req, callback) {
  
                                  // work out the tags hash
                                  var tags = articleDataSafe['tags'];
                                  var tagsArray = tags.split(",");
                                  tagsArray.sort();
                                  var tagsString = tagsArray.join(); 
                                  var hashedTags = sha512(tagsString);
                                  articleDataSafe['hashedTags'] = hashedTags;
  
                                  // then save the articles
                                  var savedArticle = saveArticle(req, articleDataSafe);
  
                                  console.log('s3');
  
                                  if(!savedArticle){
                                      var err = JSON.stringify({'error': 'notSaveArticle', 'message': 'fail'});
                                  }
  
                                  callback (err, articleDataSafe);
  
                          },
  
                          function _saveTags (articleDataSafe, callback) {
  
                                  var tagsDone = saveTags(articleDataSafe);
  
                                  if(tagsDone.length &gt; 0){
                                      // return error messages back to the browser
                                      var err = JSON.stringify({'error': tagsDone, "message": "fail"});
                                   };
                                  console.log('s4');
  
                                  callback (err, articleDataSafe);
  
                          },
  
                          function _saveTagSets (articleDataSafe, callback) {
  
                                  var tagSetsDone = saveTagSets(data);
  
                                  if(tagSetsDone.length &gt; 0){
                                      // return error messages back to the browser
                                      var err = JSON.stringify({'error': errors, "message": "fail"});
                                   };
                                  console.log('s5');
  
                                  callback (err, articleDataSafe);
  
                          }
                      ], function (error, success) {
  
                          var responseMessage = {'error': '', "message": "success"};
  
                          if (error) { 
                              responseMessage = error; 
                          } 
  
                          res.end(JSON.stringify(responseMessage));
  
                      });
  </code></pre>
  
  <p>Can any explain what is going wrong. I have been trying for ages now to get it working with no luck.</p>
  
  <p>Any help will be appreciated.</p>
  
  <p>Thanks,
  Cs1h</p>