diff --git a/index.js b/index.js index e2537fa..6cbfd41 100644 --- a/index.js +++ b/index.js @@ -36,14 +36,6 @@ const save_data = async time => { } } catch (error) { console.log("ERROR z CATCHA => " + error); - // const item = new dbSchema({ - // ip, - // status: "Urządzenie przestało działać - prawdopodobnie brak zasilania" - // }); - // item - // .save() - // .then() - // .catch(); } }; @@ -77,7 +69,7 @@ const getScript = url => { }); }) .on("error", err => { - reject(err); + resolve('{"Sensors": [{ "Switch": 2 }]}'); }); }); }; @@ -133,10 +125,10 @@ app.post("/device", async (req, res) => { res.json({ Sukces: "Dodaje OK" }); }); -app.delete("/device/:id", async (req, res) => { +app.delete("/device/:ip", async (req, res) => { console.log(req.body); - const newDevice = await deviceSchema.findByIdAndRemove(req.params.id); - await statusSchema.findOneAndRemove({ device: req.params.id }); + const newDevice = await deviceSchema.findOneAndRemove({ ip: req.params.ip }); + await statusSchema.findOneAndRemove({ device: newDevice }); res.json({ Sukces: "Usuwa OK" }); });