Firebase Cloud Functions Check Value不为空

时间:2020-05-06 09:20:51

标签: firebase google-cloud-firestore google-cloud-functions firebase-cloud-messaging

在我的云函数中,我使用JSON主体及其特定元素。

const type = request.body.type;

但是如果type是可选的呢?用户不必放它。有没有一种方法可以完成以上操作而不会出错。

因为在上述瞬间,如果用户将“类型”留在其对象之外,则将导致错误。

1 个答案:

答案 0 :(得分:2)

如果我正确理解了您的问题,则要检查FileStream fs = new FileStream("//letp.rf.servername.com/products/product.xml", FileMode.Open, FileAccess.Read); 的正文中是否有type属性。

以下应该可以解决问题:

request
相关问题