注意:body-parser已经被弃用
目前的解决方法:
// node的app.js
app.use(express.urlencoded({ extended: true }))
app.use(express.json())
// fetch请求的header一定要写明content-type
const res = await fetch('http://xxx:3000/users/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
id: id.current?.value,
pwd: pwd.current?.value
}), })