From d36de0f27397332e9680555a8350fb75add7409d Mon Sep 17 00:00:00 2001 From: Jane Petrovna Date: Sun, 6 Jun 2021 02:00:50 -0400 Subject: [PATCH] use json??? --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index bb491c3..fa2def7 100644 --- a/index.js +++ b/index.js @@ -59,8 +59,9 @@ app.get("/indexes/:project(\\w+)", (req, res) => { } }); -app.use(express.text()); -app.use(express.urlencoded()); +app.use(express.json()); +// app.use(express.urlencoded()); +// app.use(express.text()); function diff(current, checked) { let lines_current = current.split('\n').map(l => l.trim()).filter(l => l != ""); @@ -115,7 +116,7 @@ function diff(current, checked) { app.post("/updates/:project(\\w+)", (req, res) => { let project_id = req.params['project']; - const body = typeof req.body == "string" ? req.body : String(req.body); + const body = typeof req.body == "string" ? req.body : Object.keys(req.body)[0]; console.log(req.body); console.log(`${req.body}, ${typeof req.body}`); console.log(`${body}`);