PayPal服务器集成不会通过Fetch Body参数传递数据
我正在关注PayPal的服务器集成演示: https://develper..paypaler.paypal.com/dempal.com/demo/demo/checkeckout/checkout/checkout/w./pattern/服务器
以下代码似乎不是通过“正文”参数传递数据:
createOrder: function(data, actions) {
return fetch('/paypal_api', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({name:"sammy"}),
}).then(function(res) {
return res.json();
}).then(function(orderData) {
return orderData.id;
});
},
但是,我能够传递URL中的参数。例如:
返回fetch('/paypal_api/< some_variable>/',{
:
这样我就可以工作了,但是很难像预期的是邮政方法一样工作。这是我的python Server代码中的片段: class class class class CreateOrder(webapp2.requesthandler): def get feet(self):
print self.request.params
...且打印语句什么都没有返回(Unicodemultict([]))。
我99%的人肯定我缺少一些明显的东西,因为Google没有帮助我! :)
I'm following PayPal's server integration demo:
https://developer.paypal.com/demo/checkout/#/pattern/server
The following code does not appear to be passing data via the "body" parameter:
createOrder: function(data, actions) {
return fetch('/paypal_api', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({name:"sammy"}),
}).then(function(res) {
return res.json();
}).then(function(orderData) {
return orderData.id;
});
},
I am, however, able to pass parameters within the URL. For example:
return fetch('/paypal_api/<some_variable>/', {
So I can get this working but am bugged that the POST method does not appear to be working as expected. Here's a snippet from my python server code:
class createOrder(webapp2.RequestHandler):
def get(self):
print self.request.params
... and the print statement returns nothing (UnicodeMultiDict([])).
I'm 99% certain that I'm missing something obvious since google is not helping me! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将请求主体解析为JSON
Parse the request body as JSON