-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (31 loc) · 1 KB
/
Copy pathindex.js
File metadata and controls
42 lines (31 loc) · 1 KB
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
34
35
36
37
38
39
40
41
42
const express = require("express");
const app = express();
const cors = require('cors');
app.use(cors());
// google scholar stuff
const SerpApi = require('google-search-results-nodejs');
const search = new SerpApi.GoogleSearch("eaadd244ff01ebb2a33c437d6bc8baf203afd2a42edd839db7e1757e8a65d5ca");
const port = process.env.PORT || 3000;
const handleData = async (req, res) => {
return new Promise((resolve) => {
const params = {
engine: "google_scholar_author",
author_id: "7IcrxFUAAAAJ"
};
const callback = function(data) {
resolve(data);
};
search.json(params, callback);
});
};
app.get('/', cors(), async (req,res) => {
// Show result as JSON
const result = await handleData();
console.log(result);
res.json(result);
});
app.post("/", async (req, res) => {
console.log("hi!");
const { info } = req.body;
});
app.listen(port, () => console.log(`HelloNode app listening on port ${port}!`));