在我的云函数中,我使用JSON主体及其特定元素。
const type = request.body.type;
但是如果type是可选的呢?用户不必放它。有没有一种方法可以完成以上操作而不会出错。
因为在上述瞬间,如果用户将“类型”留在其对象之外,则将导致错误。
答案 0 :(得分:2)
如果我正确理解了您的问题,则要检查FileStream fs = new FileStream("//letp.rf.servername.com/products/product.xml", FileMode.Open, FileAccess.Read);
的正文中是否有type
属性。
以下应该可以解决问题:
request