Created
December 29, 2015 13:26
-
-
Save AdriVanHoudt/1b8ceddda73020b2dc1c to your computer and use it in GitHub Desktop.
Revisions
-
AdriVanHoudt renamed this gist
Dec 29, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
AdriVanHoudt created this gist
Dec 29, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ // error happens because of https://github.com/AdriVanHoudt/Hapi-Boombox/blob/master/lib/index.js#L42 exports.getAll = function (request, reply) { return Entity.getAll(request.auth.credentials.team, dbConn, (err, result) => { if (err) { return reply(err); } return Async.map(result, (item, callback) => { if (item.id) { return Entity.getSubStuff(item.id, dbConn, (err, stuff) => { if (err) { return callback(err); } item.stuff = stuff; // 3: getSubStuff is done after reply with error and calls callback return callback(null, item); }); } return Entity.getOtherStuff(request.auth.credentials.team, dbConn, (err, otherStuff) => { if (err) { // 1: errors return callback(err); } item.stuff = otherStuff; return callback(null, item); }); }, (err, results) => { // 2: call reply with error // 4: reply gets called again return reply(err, results); }); }); };