좋아요, 그렇기 때문에 이것이 필요한 것보다 더 사소한 것 같지만 어떤 이유로 get 메소드에 전달 될 때 내 "본문"에서 정보를 가져올 수 없습니다. 나는 그것에 접근하기 위해 여러 가지 다른 방법을 시도했지만, 그 트릭을 보는 것은 아무 것도 없다. 안내가 대단히 감사합니다. 당신은 req.query.phone2
및 req.query.email2
를 사용할 필요가가져 오기 방법의 가져 오기에서 데이터에 액세스하려면 어떻게해야합니까?
---------------fetch method----------------
var x = e.target.phone.value;
var y = e.target.email.value;
console.log(x); // proper output
console.log(y); // proper output
fetch('/api/insert',
{
accept: 'application/json',
body: {
phone2: x,
email2: y
}
});
------------get method--------------
app.get('/api/insert', (req, res) => {
const phone = req.body.phone2; <-- Am I accessing the data incorrectly?
const email = req.body.email2; <-- Am I accessing the data incorrectly?
console.log(phone); // getting undefined here... Why?
console.log(email); // and here...
});
});
'을 console.log (REQ)'와'을 console.log (고해상도)'의 출력은 무엇인가? – gurvinder372