-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
53 lines (49 loc) · 1.26 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
async function getData() {
let response = await fetch(
"https://api.twitter.com/2/tweets/search/recent?max_results=10&query=" +
"nepal",
{
headers: {
Authorization:
"Bearer AAAAAAAAAAAAAAAAAAAAANULlgEAAAAAXOTsDrOEK4PI%2BbH896TomP%2FiGLE%3DPwpbppKix6JP0xNmzqjeo580M36evkckKmPgSIwvjokZs3T4ff",
Cookie: "guest_id=v1%3A167656688150839753",
},
}
);
response = await response.json();
// console.log(JSON.stringify(response));
return response;
}
async function getSentiment() {}
async function sentiment(i) {
let response = await fetch("http://127.0.0.1:5000/test", {
body: i,
headers: {
"Content-Type": "application/json",
},
method: "POST",
});
response = await response.json();
return response;
}
async function main() {
console.time("new");
let totalTweets = [];
const data = await getData();
try {
await Promise.all(
data.data.map(async (d) => {
const contents = await sentiment(JSON.stringify(d));
totalTweets.push(contents);
})
);
console.log(JSON.stringify(totalTweets));
} catch (error) {
console.log(error);
} finally {
console.timeEnd("new");
}
}
main()
.then(() => console.log("done"))
.catch((e) => console.log(e));