이 작은 로그인 시스템을 구현하려고하는데 요청을 내 webpack dev 서버로 전송하는 양식이 있습니다. 요청을 프록시합니다. 내 서버에.본문 파싱 미들웨어를 사용하는 경우에도 빈 요청 본문 얻기
양식 제출을 처리하고 POST 요청을 서버에 보내는 기능입니다. 내가 로그인을 클릭하면이 당신으로 로그인 엔드 포인트
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/login', (req, res) => {
console.log('Got user information: \n', req.body);
res.send('asd');
})
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
app.listen(3001,() => {
console.log(`
=====
Server running at http://localhost:3001/
GraphiQL running at http://localhost:3001/graphiql/
=====
`)
})
을 처리하는 서버 측 코드 여기 http://prntscr.com/hsbpyp
같이
handleSubmit = (e) => {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
fetch('/login', {
method: 'POST',
body: values
});
}
});
}
, 내 값은 콘솔에 로그인합니까 볼 수 있습니다. 실제로 body-parser 미들웨어를 사용하여 req.body를 파싱했지만 몸체를 기록하려고하면 빈 객체가 생깁니다. http://prntscr.com/hsbqrd
내 코드로 무슨 일이 일어나는지 알아낼 수 있습니까?
브라우저에서 요청 페이로드를 확인 했습니까? – zabusa
네, 그 질문에 스크린 샷을 제공했는데 – buoyantair
아닙니다. 귀하의 요청에 따르면. 귀하의 전송 ... 크롬 네트워크는 무엇입니까? – zabusa