【发布时间】:2020-01-25 03:52:11
【问题描述】:
我正在尝试通过axios 将我的react 组件中的一些数据发布到我的Flask 服务器,如下所示:
handleSubmitSeeds(event) {
event.preventDefault();
const {userId} = this.props
const data = {
arabica: this.state.formSeeds
};
const url = `${process.env.REACT_APP_WEB_SERVICE_URL}/handle_seeds/${userId}`;
axios.post(url, data)
.then((res) => {
console.log(data);
})
.catch((err) => {
});
};
在后端:
@seeds_bp.route('/handle_seeds/<user_id>', methods=['GET','POST'])
def handle_seeds(user_id):
post_data = request.get_json()
arabica = post_data.get('arabica')
(...)
但我得到以下回溯:
AttributeError: 'NoneType' object has no attribute 'get'
我错过了什么?
【问题讨论】: