This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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