我正在开发一个严格使用导入的项目,这使我无法使用所需的语句。我想知道如何使用 Body Parser 的导入读取向服务器发出的发布请求的内容。
\n\n\'\'\'
\n\n//jshint esversion:6\n\n// Require the needed NPMs\n\nimport Radar from "radar-sdk-js";\nimport express from "express";\nimport bodyParser from "body-parser";\nimport { dirname } from \'path\';\nimport { fileURLToPath } from \'url\';\n\n\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst app = express();\n\napp.use(bodyParser.json());\napp.use(bodyParser.urlencoded({extended: true}));\napp.use(express.static("public"));\n\n/*app.use(bodyParser.json({\n\xc2\xa0 \xc2\xa0verify: (req, res, buf) => {\n\xc2\xa0\xc2\xa0 \xc2\xa0\xc2\xa0req.rawBody = buf;\n\xc2\xa0 }\n})*/\n\napp.get("/", function(req, res) {\n\n\xc2\xa0\xc2\xa0res.sendFile(__dirname + "/public/index.html");\n\n});\n\napp.post("/", function(req, res) {\n\n\xc2\xa0 \xc2\xa0console.log(req.body);\n\xc2\xa0 \xc2\xa0console.log(req.body.trackedName);\nRun Code Online (Sandbox Code Playgroud)\n\n\'\'\'
\n