Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Makes sure required fields are present
- if(Object.values(ticketInfo).includes(undefined)) {
- var missingFields = [];
- var ticketInfoFields = Object.keys(ticketInfo);
- //Push all missing fields to the array
- ticketInfoFields.forEach((element, index) => {
- if(ticketInfo[element] == undefined) {
- missingFields.push(Object.keys(ticketInfo)[index]);
- }
- });
- //Create the string of missing fields for the result
- var returnString = "Missing required fields: [".concat(missingFields.filter(function(el) {return el != null}).join(", "));
- //Set properties of the result before returning
- returnCode(400, res, ticketInfo, returnString, "]");
- return;
- }
Add Comment
Please, Sign In to add comment