我不知道将哪些参数传递到此Cloud Code函数(parse.com)
Parse.Cloud.define('stripe_card_create', function(req, res) {
Parse.Cloud.httpRequest({
method: 'POST',
headers: stripe_headers,
url: environment.stripe.api_url + '/customers/' + req.params.customer_id + '/sources',
params: {
source: req.params.token_id
},
success: function(card) {
res.success(card.data);
},
error: function(err) {
res.error(err.text);
}
})
});
这些应该被称为
req.customer_id(必填)客户ID
req.token_id(必填)令牌卡
但是当我使用此功能调用时,我收到错误
PFCloud.callFunctionInBackground("stripe_card_create", withParameters: ["req.params.customer_id":"req.params.token_id"])
这是错误
[Error]: {
"error": {
"type": "invalid_request_error",
"message": "No such customer: undefined",
"param": "customer"
}
}
(Code: 141, Version: 1.7.5)
1 回答
在 Cloud 功能中,
req.params.customer_id
表示英文:从
function(req, res)
中的req
, grabparams
. 从params
属性中,获取名为customer_id
的密钥 . 当您从Swift代码调用该函数时,您传递的字典键将是params
的属性 .您的 Cloud 代码需要一个密钥
customer_id
,而不是req.params.customer_id
. 你想这样做:您在Dictionary中传递的键的值也非常奇怪 . 要么是同一个错误的错误,要么你应该把它重命名为更好的东西 .