seungmi

버그 수정

분류작업이 temp.json파일생성보다 먼저 시행되도록 수정
Showing 1 changed file with 12 additions and 6 deletions
......@@ -39,7 +39,7 @@ app.get(['/food', '/food/:id'], function(req, res) {
//사용자가 호출한 search page
app.post('/food/search', function(req, res) {
var title = req.body.title;
res.render('map.ejs',{
res.render('map.ejs', {
title: 'Search',
searching: title
});
......@@ -60,13 +60,18 @@ app.post('/food/recommendation', function(req, res) {
var list = {
food: []
};
function add(users, price, shape, kinds, list, callback) {
for (var foods in users) {
if ((!price || users[foods]['price'] == price) && (!shape || users[foods]['shape'] == shape) && (!kinds || users[foods]['kinds'] == kinds)) {
list.food.push(foods);
}
// $('<li>').text(foods).appendTo('#users');
}
callback(list);
}
add(users, price, shape, kinds, list, function(list) {
fs.writeFile('data/temp.json', JSON.stringify(list), "utf8", function(err) {
if (err) {
console.log(err);
......@@ -87,15 +92,16 @@ app.post('/food/recommendation', function(req, res) {
title: 'Recommendation',
description: 'We recommend this...',
randvalue: food_value
});//rander closed
}); //rander closed
}
});//readFile closed
}); //readFile closed
}
});//writeFile closed
}); //writeFile closed
});//add closed
}
});//readFile closed
});//post closed
}); //readFile closed
}); //post closed
......