-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
26 lines (21 loc) · 1.12 KB
/
example.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
const NineGag = require("./index"); // const NineGag = require("9gag.js");
(async () => {
// Fetch the first page of the hot section
let hot = await NineGag.getType({ type: "hot" });
console.log(hot["posts"]);
// Fetch comments of the first post in the hot section
let comments = await NineGag.getComments({ id: hot["posts"][0]["id"] });
console.log(comments);
// Getting page 2 of hot section
let hotPage2 = await NineGag.getType({ type: "hot", cursor: hot["cursor"] });
console.log(hotPage2["posts"]);
// Getting page 2 of specified post's comments
let commentsPage2 = await NineGag.getComments({ id: hot["posts"][0]["id"], orderKey: comments[comments.length - 1]["orderKey"] });
console.log(commentsPage2);
// Simplified view of the hot section page 1
let simplifiedHot = await NineGag.getType({ type: "hot", simplified: true });
console.log(simplifiedHot["posts"]);
// Fetch simplified comments of the first post in the hot section
let comments = await NineGag.getComments({ id: simplifiedHot["posts"][0]["id"], simplified: true });
console.log(comments);
})();