我正在命令提示符中接收此输出,我在那里使用python flask打印它
ImmutableMultiDict([('{"amount":1000,"description":"test
product","id":"tok_1BzM5eKliAs5iPakCZJ90MNY"}', '')])
我希望从中提取数量,描述和ID 在烧瓶中接收它的代码
data = request.form
print (data)
return ''
从我的前端我发送它
onToken = (amount) => token => {
token.amount = fromRupeeToPaise(amount);
token.currency = localCurrency;
var requestOptions = {
"method": "POST",
"headers": {
"Accept": "application/json",
//"Content-Type": "application/json ; charset=utf-8"
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"
}
};
const toktest ={
amount : 1000,
description : "test product",
id : token.id
}
requestOptions["body"] = JSON.stringify(toktest);
//requestOptions["body"] = JSON.stringify(token);
fetch('http://localhost:5000/pay', requestOptions)
答案 0 :(得分:0)
尝试使用'键'
在JSON中获取请求和获取<强>实施例强>
const last = this.sets.find(s => s.id === res.body.last_id);
if (last) {
Object.assign(last, this.editForm);
last.user_id = this.userId;
}
或者:
data = request.get_json()
print data['amount']