我在这里测试一些东西,我有一个非常基本的 HTML 前端,我将一些数据发送到后端,我正在使用 javascript 获取,我发送一个请求,当我将它保存在数据库中时,值出现作为 NULL ,为什么?
我有以下代码。
<!DOCTYPE html>
<body>
<button onclick="test()">To Send</button>
<body>
<script>
function test(){
const data = { name: "Anderson" };
fetch('http://localhost:8081/user', {
method: 'POST',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
}).then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error))
}
<script>