Json 使用post方法向服务器添加新数据无效。使用Reactjs和nodejs

Json 使用post方法向服务器添加新数据无效。使用Reactjs和nodejs,json,ajax,node.js,express,Json,Ajax,Node.js,Express,我不确定使用ajax将数据从客户端发送到服务器的方法。我现在正在使用Post。下面是我的代码plz回顾。谢谢你 这是我的客户端代码 $.ajax( { url: "/api/addTemplateToDb", type: 'POST', data:{ "Name": tempName.value,

我不确定使用ajax将数据从客户端发送到服务器的方法。我现在正在使用Post。下面是我的代码plz回顾。谢谢你

这是我的客户端代码

$.ajax(
            {
                url: "/api/addTemplateToDb",
                type: 'POST',
                data:{
                    "Name": tempName.value,
                    "Version": "1.0",
                    "Data": "{"+ tempData.value +"}"
                },
                success: function(result) {
                    console.log(result);
                }.bind(this),
                error:function(result) {
                    console.log(result.responseText);
                }
            }
        );
这是我的服务器端(节点)代码


我在服务器中得到一个未定义的输出。

在服务器端插入这两行(它解析正文)
var-bodyParser=require('body-parser');

use(bodyParser.urlencoded({extended:true}))在服务器端插入这两行(它解析正文)
var-bodyParser=require('body-parser');
use(bodyParser.urlencoded({extended:true}))
app.post('/api/addTemplateToDb', function (req, res) {

console.log(req.body.Name); })