내가 노력하고 웹을 만드는 업로드 파일 첨부된 현재 사용자는 파일한 모델로 외국인 핵심이다. 이는 get 요청이 초기화 되지만,그것은 처음에 필요한 정보입니다.
handleSubmit = (e) => {
e.preventDefault();
axios.get('http://127.0.0.1:8000/core/current_user/', {
headers: {
Authorization: `JWT ${localStorage.getItem('token')}`,
}
}).then((user) => {
this.state.creator = user.data;
console.log(this.state.creator);
})
console.log(this.state.creator);
let form_data = new FormData();
form_data.append('creator', this.state.creator);
form_data.append('file', this.state.file);
form_data.append('title', this.state.title);
form_data.append('description', this.state.description);
axios.post('http://localhost:8000/core/posts/', form_data, {
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `JWT ${localStorage.getItem('token')}`,
}
}).then(res => {
console.log(res.data);
}).catch(err => console.log(err))
};
1 호 콘솔은 사용자 정보 그러나 2 차 콘솔 null 을 반환합니다. 어떤 도움이 될 것입니다 정말 감사합니다.