Showing
1 changed file
with
16 additions
and
6 deletions
| ... | @@ -16,9 +16,11 @@ const bodyParser = require('body-parser'); | ... | @@ -16,9 +16,11 @@ const bodyParser = require('body-parser'); |
| 16 | var app = express(); | 16 | var app = express(); |
| 17 | var stack = 0; | 17 | var stack = 0; |
| 18 | var meal, country, cold, spicy, name; //name 추가 | 18 | var meal, country, cold, spicy, name; //name 추가 |
| 19 | -const FoodArray; //meal, country, cold, spicy를 이용해 해당 객체를 가져오는 배열변수 | ||
| 20 | 19 | ||
| 21 | -const FoodData = fs.readFileSync("./FoodList.json", {encoding:"utf-8"}); //FoodData 객체 | 20 | + |
| 21 | +const FoodData = fs.readFileSync("./FoodList.json", {encoding:"utf-8"}); //FoodData 객체 (OK) | ||
| 22 | + | ||
| 23 | + | ||
| 22 | 24 | ||
| 23 | app.use(bodyParser.json()); | 25 | app.use(bodyParser.json()); |
| 24 | app.post('/hook', function (req, res) { | 26 | app.post('/hook', function (req, res) { |
| ... | @@ -189,12 +191,20 @@ https://developers.naver.com/docs/search/local/ | ... | @@ -189,12 +191,20 @@ https://developers.naver.com/docs/search/local/ |
| 189 | 로컬 변수 값을 바탕으로 name을 JSON파일에서 찾기 | 191 | 로컬 변수 값을 바탕으로 name을 JSON파일에서 찾기 |
| 190 | */ | 192 | */ |
| 191 | 193 | ||
| 194 | + | ||
| 195 | + | ||
| 192 | // arr은 해당 JSON값을 가진 객체를 출력함 | 196 | // arr은 해당 JSON값을 가진 객체를 출력함 |
| 193 | - FoodData.filter(function(e){ | 197 | + |
| 194 | - FoodArray = e.meal === meal && e.country === country && e.spicy === spicy && e.cold === cold; | 198 | + |
| 195 | - }) | ||
| 196 | 199 | ||
| 197 | - name = FoodArray[name]; //name에 해당 속성에 맞는 음식 이름을 삽입 | 200 | + var parseObject = Object.values(FoodObject).filter(function(e){ |
| 201 | + return e.meal === meal && e.country === country && e.spicy === spicy && e.cold === cold; | ||
| 202 | + }); | ||
| 203 | + | ||
| 204 | + | ||
| 205 | + name = parseObject[0].name; | ||
| 206 | + | ||
| 207 | + | ||
| 198 | 208 | ||
| 199 | request.post( | 209 | request.post( |
| 200 | { | 210 | { | ... | ... |
-
Please register or login to post a comment