Today, when I wrote the back-end code, I couldn't get the parameters passed by the front-end. Why did the post request not get the parameters in the normal way?
Front-end vue
back-end flask
Back-end code
@app.route('/planFile', methods=['POST'])
def downloadPlanData():
planId = request.from.get('planId') # 正常接受post请求参数的一种方式
FIG reasons
noted above figure is post request parameter passing Request Payload
mode so used request.from.get('planId')
to acquire not only the parameters are acquired in the following figure Form Data
only mode can receive parameters
So use Request Payload
in the end how to receive the parameters when it passed by
Solution
Two ways
-
Front-end to resolve (the idea is to
Request Payload
fashion intoForm Data
a limited ability to change the way Zenmo not answer here) -
The rear end to solve the
flask usedrequest.json.get('planId')
may receive parameters@app.route('/planFile', methods=['POST']) def downloadPlanData(): planId = request.json.get('planId')
The overall reason is that the front-end and back-end methods of passing and receiving parameters are not unified. The
solution is to unify the method of parameter transfer.