Hacker News new | comments | show | ask | jobs | submit login

Don't forget to bubble errors up the callback chain along with return values (I always forget that too):

    getFromCache = function (id, query, callback) {
      asynchronousCache.get(['id', id].join(':'), function(err, myThing) {
        if (myThing == null) {
          asynchronousDB.query(query, function(err, myThing) {
            callback(err, myThing);
          });
        }
        else {
          callback(err, myThing);
        }
      });
    };



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: