Showing
1 changed file
with
38 additions
and
37 deletions
... | @@ -129,44 +129,10 @@ app.post('/hook', function (req, res) { | ... | @@ -129,44 +129,10 @@ app.post('/hook', function (req, res) { |
129 | } | 129 | } |
130 | res.sendStatus(200); | 130 | res.sendStatus(200); |
131 | 131 | ||
132 | - chooseFile = function () { | 132 | + |
133 | - if (destCar == "cafe") { | 133 | + chooseFile(); |
134 | - fs.createReadStream('cafe_list.csv') | 134 | + |
135 | - .pipe(csv()) | ||
136 | - .on('data', (data) => results.push(data)) | ||
137 | - .on('end', () => { | ||
138 | - console.log(results); | ||
139 | - }); | ||
140 | - } | ||
141 | - else if (destCar == "meal") { | ||
142 | - fs.createReadStream('meal_list.csv') | ||
143 | - .pipe(csv()) | ||
144 | - .on('data', (data) => results.push(data)) | ||
145 | - .on('end', () => { | ||
146 | - console.log(results); | ||
147 | - }); | ||
148 | - } | ||
149 | - else if (destCar == "play") { | ||
150 | - fs.createReadStream('play_list.csv') | ||
151 | - .pipe(csv()) | ||
152 | - .on('data', (data) => results.push(data)) | ||
153 | - .on('end', () => { | ||
154 | - console.log(results); | ||
155 | - }); | ||
156 | - } | ||
157 | - else if (destCar == "bar") { | ||
158 | - fs.createReadStream('bar_list.csv') | ||
159 | - .pipe(csv()) | ||
160 | - .on('data', (data) => results.push(data)) | ||
161 | - .on('end', () => { | ||
162 | - console.log(results); | ||
163 | - }); | ||
164 | - } | ||
165 | - } | ||
166 | - | ||
167 | - chooseFile(); | ||
168 | 135 | ||
169 | - | ||
170 | }); | 136 | }); |
171 | 137 | ||
172 | try { | 138 | try { |
... | @@ -186,3 +152,38 @@ try { | ... | @@ -186,3 +152,38 @@ try { |
186 | 152 | ||
187 | const csv = require('csv-parser') | 153 | const csv = require('csv-parser') |
188 | const results = []; | 154 | const results = []; |
155 | + | ||
156 | +chooseFile = function () { | ||
157 | + if (destCar == "cafe") { | ||
158 | + fs.createReadStream('cafe_list.csv') | ||
159 | + .pipe(csv()) | ||
160 | + .on('data', (data) => results.push(data)) | ||
161 | + .on('end', () => { | ||
162 | + console.log(results); | ||
163 | + }); | ||
164 | + } | ||
165 | + else if (destCar == "meal") { | ||
166 | + fs.createReadStream('meal_list.csv') | ||
167 | + .pipe(csv()) | ||
168 | + .on('data', (data) => results.push(data)) | ||
169 | + .on('end', () => { | ||
170 | + console.log(results); | ||
171 | + }); | ||
172 | + } | ||
173 | + else if (destCar == "play") { | ||
174 | + fs.createReadStream('play_list.csv') | ||
175 | + .pipe(csv()) | ||
176 | + .on('data', (data) => results.push(data)) | ||
177 | + .on('end', () => { | ||
178 | + console.log(results); | ||
179 | + }); | ||
180 | + } | ||
181 | + else if (destCar == "bar") { | ||
182 | + fs.createReadStream('bar_list.csv') | ||
183 | + .pipe(csv()) | ||
184 | + .on('data', (data) => results.push(data)) | ||
185 | + .on('end', () => { | ||
186 | + console.log(results); | ||
187 | + }); | ||
188 | + } | ||
189 | + } | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment