From 01709c890d75fc69a0b6e2456863f08fecf58abb Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Mon, 16 Jan 2023 15:21:30 +0100 Subject: [PATCH] first message command test --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index f2be829..636f831 100644 --- a/index.js +++ b/index.js @@ -5,15 +5,17 @@ const express = require('express'); const app = express(); const clientPath = __dirname+'/../html'; console.log('Serving static from ' + clientPath); +app.use(express.json()); app.use(express.static(clientPath)); const server = http.createServer(app); app.post('/message', (req, res) => { - res.status(200).send(req.body); + const { user, message } = req.body; + res.status(200).json({message}); }); server.on('error', err => { - console.error('Internal server error:', err); + console.error('Internal server error', err); }); server.on('close', () => {