Skip to content

Commit

Permalink
Show array scraped from web
Browse files Browse the repository at this point in the history
  • Loading branch information
yudetamago committed Sep 6, 2021
1 parent fab4cce commit 9ab4ae4
Showing 1 changed file with 33 additions and 22 deletions.
55 changes: 33 additions & 22 deletions src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,30 +57,41 @@ export const getData = async (req, res) => {

export const saveData = (req, res) => {

const finalResult = getData();
console.log(finalResult);
let data = [];

return res.end();


/*for (var i = 0; i < tempArray.length; i++) {
console.log(tempArray[i].date);
try {
const exist = await Article.findOne({ date: tempArray[i].date})
(async () => {
data = await getData();

if(exist) {
console.log(`${tempArray[i]} already exist`);
res.end();
} else {
await Article.create(tempArray[i]);
console.log(`${tempArray[i]} added`);
for (var i = 0; i < data.length; i++) {
console.log(data[i].date);

try {
const exist = await Article.findOne({ date: data[i].date})

if(exist) {
console.log(`${data[i]} already exist`);
res.end();
} else {
await Article.create(data[i]);
console.log(`${data[i]} added`);
res.end();
};

} catch(e) {
console.log(e);
res.end();
};
} catch(e) {
console.log(e);
res.end();

};
};*/

};

})();

if (data.length === 0) {
setTimeout(function() {
console.log("wait for data coming");
}, 1000)
};

return res.end();

};

0 comments on commit 9ab4ae4

Please sign in to comment.