Showing
7 changed files
with
60 additions
and
10 deletions
testcode/@
0 → 100644
1 | +var express = require('express'); | ||
2 | +var router = express.Router(); | ||
3 | + | ||
4 | +const Xports = require('../test1.js'); | ||
5 | +const Zum = require('../test2.js'); | ||
6 | +const Chosun = require('../test3.js'); | ||
7 | +const zum = Zum.zum; | ||
8 | +const chosun = Chosun.chosun; | ||
9 | + | ||
10 | +exports().then(a => { | ||
11 | + console.log(a); | ||
12 | +}); | ||
13 | + | ||
14 | +const xports = new Array(); | ||
15 | + | ||
16 | +router.get('/', function(req, res, next){ | ||
17 | + | ||
18 | + res.render('index', { | ||
19 | + xports : xports, | ||
20 | + zum : zum, | ||
21 | + chosun : chosun, | ||
22 | + // yna : yna | ||
23 | + }); | ||
24 | +}); | ||
25 | + | ||
26 | +console.log("aaaa\n"); | ||
27 | +for(var i in xports){ | ||
28 | + console.log("aaaa\n"); | ||
29 | + console.log(i.datetime); | ||
30 | +} | ||
31 | +module.exports = router; |
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | var router = express.Router(); | 2 | var router = express.Router(); |
3 | 3 | ||
4 | -const Xports = require('../test1.js'); | 4 | +const getXports = require('../test1.js'); |
5 | const Zum = require('../test2.js'); | 5 | const Zum = require('../test2.js'); |
6 | const Chosun = require('../test3.js'); | 6 | const Chosun = require('../test3.js'); |
7 | -const Yna = require('../test4.js'); | ||
8 | -const xports = Xports.xports; | ||
9 | const zum = Zum.zum; | 7 | const zum = Zum.zum; |
10 | const chosun = Chosun.chosun; | 8 | const chosun = Chosun.chosun; |
11 | -const yna = Yna.yna; | 9 | + |
10 | +let xports; | ||
11 | +(async function() { | ||
12 | +try { | ||
13 | + xports = await getXports(); | ||
14 | + console.log(xports); | ||
15 | +} catch (e) { | ||
16 | + return console.log(e); | ||
17 | +} | ||
18 | +})(); | ||
12 | 19 | ||
13 | router.get('/', function(req, res, next){ | 20 | router.get('/', function(req, res, next){ |
14 | 21 | ||
... | @@ -16,11 +23,13 @@ router.get('/', function(req, res, next){ | ... | @@ -16,11 +23,13 @@ router.get('/', function(req, res, next){ |
16 | xports : xports, | 23 | xports : xports, |
17 | zum : zum, | 24 | zum : zum, |
18 | chosun : chosun, | 25 | chosun : chosun, |
19 | - yna : yna | 26 | + // yna : yna |
20 | }); | 27 | }); |
21 | }); | 28 | }); |
22 | 29 | ||
30 | +console.log("aaaa\n"); | ||
23 | for(var i in xports){ | 31 | for(var i in xports){ |
32 | + console.log("aaaa\n"); | ||
24 | console.log(i.datetime); | 33 | console.log(i.datetime); |
25 | } | 34 | } |
26 | module.exports = router; | 35 | module.exports = router; | ... | ... |
... | @@ -13,7 +13,11 @@ const getHtml = async () => { | ... | @@ -13,7 +13,11 @@ const getHtml = async () => { |
13 | } | 13 | } |
14 | }; | 14 | }; |
15 | 15 | ||
16 | -getHtml() | 16 | + |
17 | +const getXports = async () => { | ||
18 | + | ||
19 | + return new Promise((resolve, reject) => { | ||
20 | + getHtml() | ||
17 | .then(html => { | 21 | .then(html => { |
18 | let ulList = []; | 22 | let ulList = []; |
19 | //console.log(html.data); | 23 | //console.log(html.data); |
... | @@ -34,4 +38,10 @@ getHtml() | ... | @@ -34,4 +38,10 @@ getHtml() |
34 | const data = ulList.filter(n => n.title); | 38 | const data = ulList.filter(n => n.title); |
35 | return data; | 39 | return data; |
36 | //return ulList; | 40 | //return ulList; |
37 | - }).then(res => console.log(res)); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
41 | + }).then(data => { | ||
42 | + resolve(data); | ||
43 | + }); | ||
44 | +}); | ||
45 | +}; | ||
46 | + | ||
47 | +module.exports = getXports; | ... | ... |
... | @@ -31,4 +31,4 @@ getHtml() | ... | @@ -31,4 +31,4 @@ getHtml() |
31 | const data = ulList.filter(n => n.title); | 31 | const data = ulList.filter(n => n.title); |
32 | return data; | 32 | return data; |
33 | //return ulList; | 33 | //return ulList; |
34 | - }).then(res => console.log(res)); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
34 | + }); | ... | ... |
... | @@ -31,4 +31,4 @@ getHtml() | ... | @@ -31,4 +31,4 @@ getHtml() |
31 | const data = ulList.filter(n => n.title); | 31 | const data = ulList.filter(n => n.title); |
32 | return data; | 32 | return data; |
33 | //return ulList; | 33 | //return ulList; |
34 | - }).then(res => console.log(res)); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
34 | + }); | ... | ... |
... | @@ -10,7 +10,7 @@ | ... | @@ -10,7 +10,7 @@ |
10 | <div class = 'main'> | 10 | <div class = 'main'> |
11 | <div class = 'center'> | 11 | <div class = 'center'> |
12 | <div> | 12 | <div> |
13 | - <% for(var i in xports) { %> | 13 | + <% for(var i of xports) { %> |
14 | <li> | 14 | <li> |
15 | <div class='item'> | 15 | <div class='item'> |
16 | <div class='info'> | 16 | <div class='info'> | ... | ... |
-
Please register or login to post a comment