如果条件columnName ==' name'
,我收到错误receivedValues = req.body
var usercolumns = ["name","price","duration","gender"];
//FOR VALIDATING VALUES BEFORE SUBMISSION
for(var iter=0;iter<usercolumns.length;iter++)
{
columnName = usercolumns[iter];
console.log("column name",columnName);
if(receivedValues[columnName] == undefined && (columnName=='name' || columnName=='price' || columnName=='duration' || columnName=='gender'))
{
答案 0 :(得分:2)
此处receivedValues
变量似乎未定义,您应该添加更多代码进行提问。
答案 1 :(得分:0)
if(receivedValues && receivedValues[columnName] == undefined && (columnName=='name' || columnName=='price' || columnName=='duration' || columnName=='gender'))
您需要检查 receivedValues 是否存在
您可以优化代码:
if(receivedValues && !columnName in receivedValues && columnName in usercolumns)