客户端可调用的Firebase函数在部署到us-central1(尝试过的欧洲、西方和亚洲)以外的地区时失败,并显示“错误:数据格式不正确,无法读取”。
服务器代码
exports.getName = functions.region('europe-west1').https.onCall((data, context) => {
return { name: "Testopoulos" };
});
客户端代码
(
React Native Firebase
)
const httpsCallableUserName = firebase.functions().httpsCallable('getName');
getUserName = () => {
httpsCallableUserName()
.then(({ data }) => {
console.log(data.name);
})
.catch(httpsError => {
console.log(httpsError);
})
}
在
docs
说“[当]使用HTTP函数为宿主提供动态内容时,必须使用us-central1”,但我只是将一个对象返回到我们的前端React本机客户端,而不是使用Firebase宿主。我读过其他关于这些地区的文章,但我不认为是同一个情况。有什么想法吗?