发出http请求时,为什么我的数据未定义?

时间:2020-02-21 09:45:54

标签: node.js angular express

当我将数据发送到API req时,后端出现问题。body向我发送了空{} 突然我不明白为什么我无法恢复我的数据,但是在正面我很好地发送了数据?

enter image description here

enter image description here enter image description here enter image description here

2 个答案:

答案 0 :(得分:0)

如果您使用的是表单数据,请添加如下所示的url编码解析器:

app.use(express.urlencoded({extended : true}));
app.use(express.json());

将此添加到创建服务器的主服务器文件中

答案 1 :(得分:-1)

这可能是变量的顺序,没有尝试过,但这是唯一可以坚持的事情。当您发送其{email,name,password2,password}时,但是当您接收其{name,email,password,password2}

编辑:具有讽刺意味的答复时弄乱了变量顺序

相关问题