【发布时间】:2019-11-26 17:25:10
【问题描述】:
我正在使用 Firebase 云功能。在 iOS 设备上,我部署了一个触发器以在 Node.Js 中运行云功能。在 Xcode 中 - 这是我触发 Cloud 功能的客户端函数 - 我正在传递字典 data
func updateTermsOfServiceCloudCall(){
let data = [
"accountId": "acct_1Ew#######"
]
Functions.functions().httpsCallable("updateAccountWithTOA").call(data) { (result, error) in
}
现在在 Node 中,我正在运行此代码以部署到 Firebase 云
exports.updateAccountWithTOA = functions.https.onRequest((request, response) => {
const data = request.body;
const accoundId = data.accoundId;
stripe.accounts.update(
accoundId,
{
tos_acceptance: {
date: Math.floor(Date.now() / 1000),
ip: request.ip
}
},
)
});
我希望得到我从 iOS 客户端传递过来的字典 data。但是,我在 Node.js 中获取该数据时遇到问题。我以为 request.body 会给我数据,但我猜我错了,因为我收到了这个错误。任何帮助或建议将不胜感激。谢谢
错误:条纹:参数“id”必须是字符串,但得到:未定义(在 API请求
POST /accounts/{id})
【问题讨论】:
标签: node.js swift firebase google-cloud-functions stripe-payments