-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (25 loc) · 840 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const express = require("express");
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const server = app.listen(process.env.PORT || 8080);
const port = server.address().port;
console.log("App now running on port", port);
app.post('/', async (req, res) => {
// console.log({ req });
// console.log( Object.keys(req) );
//
const { tag, limit = 2 } = req.body;
console.log({ tag, limit });
const { scrapeTag } = require('./scrapeIG.js');
let hashTagData
try {
hashTagData = await scrapeTag(tag, limit);
console.log({hashTagData})
return res.status(200).json({hashTagData});
} catch( error ) {
console.log(error);
return res.status(500).json({success: false});
}
});