且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

身份验证触发的云功能(创建用户)未执行

更新时间:2023-12-03 10:17:04

我的问题是我尝试设置的对象.挖掘完它(云功能的新增功能)后,我在云功能中看到了以下消息:

My problem was with the object I was trying to set. After digging a it (new to cloud functions) I saw in the cloud functions log this message:

Error: Value for argument "data" is not a valid Firestore document. Couldn't serialize object of type "MyUser" (found in field newUser). Firestore doesn't support JavaScript objects with custom prototypes (i.e. objects that were created via the "new" operator).

在寻找解决方案之后,我意识到我需要更改这一行:

After searching for a solution for this I realized I need to change this line:

return db.doc("users/"+user.uid).set({newUser});

对此

return db.doc('users/'+user.uid).set(JSON.parse(JSON.stringify(newUser)));

现在可以使用了.