我正在使用 Firebase 云功能。在 iOS 设备上,我部署了一个触发器以在 Node.Js 中运行云功能。在 Xcode 中 - 这是我的客户端函数来触发 Cloud 函数 - 我正在传递字典数据
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 客户端传递过来的字典数据。但是,我在 Node.js 中获取该数据时遇到问题。我以为request.body会给我数据,但我猜我错了,因为我收到了这个错误。任何帮助或建议将不胜感激。谢谢
错误:条纹:参数“id”必须是字符串,但得到:未定义(根据 API 请求
POST /accounts/{id}
)