이이이이 POST를 처리하는 서버 엔드 포인트 인 POST포스트에 실패 반작용 응용 프로그램
class HomePage extends React.Component{
......
handleSubmit(data){
......
postData(post_url, this.state.user.yguid, this.state.receiverId, this.state.mediaId);
}
render(){
return(
<div className="col-md-2 left-pane">
<Sidebar handleSubmit= {this.handleSubmit}/>
</div>
);
}
}
을 만드는 구성 요소입니다
export function postData(url, senderId, receiverId, mediaId){
return fetch(url, { headers: { 'Content-type': 'application/json' },
credentials: 'include',
mode: 'no-cors',
method: 'POST',
body: JSON.stringify({"senderId": senderId, "receiverId": receiverId, "mediaId": mediaId})
})
.then((response) => { console.log('Status: ', response.status);})
.catch((error) =>{ console.log("Request failed: ", error) ;
});
}
내가 데이터를 게시하는 사용하고 기능이며,
@RequestMapping(value = "/send/",
method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<Void> send(@RequestBody Message message) {
try {
controller.send(message);
} catch (Exception e) {
}
return new ResponseEntity(HttpStatus.OK);
}
나는 다음과 같은 오류 메시지가 계속
POST http://localhost:9000/myserver/send/ 415()
내가 뭘 잘못하고 있니?
서버에 오류가 발생했습니다. '/ send' 라우트에 대한 코드를 모른 채이 질문에 답하는 것은 불가능합니다. 유용한 로그 정보가 있는지 서버 로그를 확인하십시오. –
엔드 포인트는 정상적으로 작동하며 우편 배달부에서 테스트했습니다. –
@AndyRay 질문을 서버 코드로 업데이트했습니다. –