Skip to content

Instantly share code, notes, and snippets.

@lcfd
Last active September 29, 2020 22:22
Show Gist options
  • Save lcfd/d047a94153573dd32dfc5bcd3256bbd9 to your computer and use it in GitHub Desktop.
Save lcfd/d047a94153573dd32dfc5bcd3256bbd9 to your computer and use it in GitHub Desktop.
import * as colors from "https://deno.land/std/fmt/colors.ts";
const BASE_PATH = "https://hacker-news.firebaseio.com/v0/";
const get_top_stories = async () => {
console.info(
`
/$$ /$$ /$$ /$$ /$$
| $$ | $$ | $$ | $$$ | $$
| $$ | $$ /$$$$$$ /$$$$$$$| $$ /$$ /$$$$$$ /$$$$$$ | $$$$| $$ /$$$$$$ /$$ /$$ /$$ /$$$$$$$
| $$$$$$$$ |____ $$ /$$_____/| $$ /$$/ /$$__ $$ /$$__ $$ | $$ $$ $$ /$$__ $$| $$ | $$ | $$ /$$_____/
| $$__ $$ /$$$$$$$| $$ | $$$$$$/ | $$$$$$$$| $$ \\__/ | $$ $$$$| $$$$$$$$| $$ | $$ | $$| $$$$$$
| $$ | $$ /$$__ $$| $$ | $$_ $$ | $$_____/| $$ | $$\\ $$$| $$_____/| $$ | $$ | $$ \\____ $$
| $$ | $$| $$$$$$$| $$$$$$$| $$ \\ $$| $$$$$$$| $$ | $$ \\ $$| $$$$$$$| $$$$$/$$$$/ /$$$$$$$/
|__/ |__/ \\_______/ \\_______/|__/ \\__/ \\_______/|__/ |__/ \\__/ \\_______/ \\_____/\\___/ |_______/
`
);
console.info("💭 Loading... \n");
const request_topstories = await fetch(`${BASE_PATH}beststories.json`, {
method: "GET",
});
let story_details = [];
const stories = await request_topstories.json();
const top_ten = stories.slice(0, 10);
for (let i = 0; i < top_ten.length; i++) {
const s = top_ten[i];
const request_story = await fetch(`${BASE_PATH}item/${s}.json`, {
method: "GET",
});
const story = await request_story.json();
if (i === 0) {
console.log(
"================================================================================================"
);
}
console.log(colors.green(`${story.title}`));
console.log(colors.blue(`🔗${" "}${story.url}`));
console.log(
"================================================================================================"
);
}
};
get_top_stories();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment