Sfoglia il codice sorgente

Merge branch 'development'

Lee Morgan 5 anni fa
parent
commit
471daa4837
1 ha cambiato i file con 6 aggiunte e 2 eliminazioni
  1. 6 2
      controllers/recipeData.js

+ 6 - 2
controllers/recipeData.js

@@ -137,7 +137,11 @@ module.exports = {
         //get property locations
         let locations = {};
         for(let i = 0; i < array[0].length; i++){
-            switch(array[0][i].toLowerCase()){
+            let title = "";
+            try{title = array[0][i].toLowerCase()}
+            catch{title = ""}
+
+            switch(title){
                 case "name": locations.name = i; break;
                 case "price": locations.price = i; break;
                 case "ingredients": locations.ingredient = i; break;
@@ -166,7 +170,7 @@ module.exports = {
                 let recipes = [];
                 let currentRecipe = {};
                 for(let i = 1; i < array.length; i++){
-                    if(array[i].length === 0){
+                    if(array[i][locations.ingredient] === undefined){
                         continue;
                     }