콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

This my code but now controller not get value FromData from client


1. Controller

@http.route("/test-form-data", methods=["POST"], auth="user", csrf=False, type="http")
def test(self, **kwargs):
print(http.request.httprequest.form)
return json.dumps({})

2. Js

class TEST extends Component {
setup() {
super.setup();
this.state = useState({
form: {
name: '',
selection: 'cat',
note: '',
file: null
}
})
}

handleSubmit = async (e) => {
e.preventDefault()
const formData = new FormData();
formData.append('name', this.state.form.name);
formData.append('selection', this.state.form.selection);
formData.append('note', this.state.form.note);
formData.append('file', this.state.form.file);
const response = await fetchApi("/test-form-data", "POST", {}, formData)
}
}

3. html
















id="ycgd_file"/>


Currently, the frontend can send data to the backend in json form, but when sending using formdata, the backend does not receive the data.

아바타
취소
관련 게시물 답글 화면 활동
1
2월 24
2135
0
3월 24
1372
3
2월 24
3129
1
5월 23
2528
4
10월 20
5675