When collection is undefined on where filter, we got: "TypeError: Cannot read property 'filter' of undefined" A simple check solve the problem. if(!collection)) { return false; }