diff --git a/Rev1/node/public/js/flasher.js b/Rev1/node/public/js/flasher.js new file mode 100644 index 0000000..380a172 --- /dev/null +++ b/Rev1/node/public/js/flasher.js @@ -0,0 +1,25 @@ +console.log("starting"); +fetch("http://localhost:3000/flasher/getProjects", { + method: "POST", + body: "body", + headers: { + // "Content-Type": "multipart/form-data", + // "content-type": "text/html; charset=utf-8", + }, +}) + .then(function (res) { + console.log("hello world"); + console.log(res); + location.reload(); + }) + .catch((err) => ("Error occured", err)); + +var socket = io(); + +form.addEventListener("submit", function (e) { + e.preventDefault(); + if (input.value) { + socket.emit("chat message", input.value); + input.value = ""; + } +}); diff --git a/Rev1/node/routes/flasher.js b/Rev1/node/routes/flasher.js index b2d9bdf..f7ea06a 100644 --- a/Rev1/node/routes/flasher.js +++ b/Rev1/node/routes/flasher.js @@ -20,9 +20,10 @@ const router = express.Router(); // }); // }); -router.post("/getRides", function (req, res, next) { +router.post("/getProjects", function (req, res, next) { + console.log("yes there is a request"); var io = req.app.get("io"); - + io.emit("world", "This will emit projects"); // io.to(//socket.id//).emit("message", data); // db.rides.find(function(err, docs) { diff --git a/Rev1/node/views/flasher.pug b/Rev1/node/views/flasher.pug index 8001248..22d4017 100644 --- a/Rev1/node/views/flasher.pug +++ b/Rev1/node/views/flasher.pug @@ -1,6 +1,7 @@ extends layout.pug block content script(src='/socket.io/socket.io.js') + script(src='/js/flasher.js') h3.text-center.mt-3 Flasher .container .row