diff --git a/index.js b/index.js index b05f7bb..92148ca 100644 --- a/index.js +++ b/index.js @@ -54,6 +54,14 @@ app.post("/api/send/:jobid/:id/", (req, res) => { var id = req.params.id; var stats = ws_[id]; var socket = ws_[id].connection; + // Catch if body is not json data + if (!req.body.data) { + res.status(400).send({ + success: false, + message: "No data provided" + }); + return; + } console.log("sent data: " + req.body) if (stats.open == true) { socket.send(req.body.data);