From a6b1c4139a485595fd858fa447d893725d43a015 Mon Sep 17 00:00:00 2001 From: schneefux Date: Tue, 4 Apr 2017 21:03:28 +0200 Subject: filter undefined or null objects --- worker.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worker.js b/worker.js index d0d6ca0..b277eca 100644 --- a/worker.js +++ b/worker.js @@ -64,8 +64,10 @@ var RABBITMQ_URI = process.env.RABBITMQ_URI || "amqp://localhost", // processor sends to queue with a custom "type" so compiler can filter // m.content: player.api_id - let players = msgs.filter((m) => m.properties.type == "player").map((m) => JSON.parse(m.content)), - participants = msgs.filter((m) => m.properties.type == "participant").map((m) => JSON.parse(m.content)); + let players = msgs.filter((m) => m.properties.type == "player").map( + (m) => JSON.parse(m.content)).filter((p) => p != undefined), + participants = msgs.filter((m) => m.properties.type == "participant").map( + (m) => JSON.parse(m.content)).filter((p) => p != undefined); // collect information and populate _record arrays await Promise.all([ -- cgit v1.3.1