From 2f973f910ba236542e99765c3544064d2c0d388c Mon Sep 17 00:00:00 2001 From: Volpeon Date: Mon, 18 Oct 2021 13:57:48 +0200 Subject: Better interfaces and function responsibilities --- src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts index e2fee01..3b8b0a8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,7 +19,9 @@ const args = cliArgs.parse<{ async function postRandomPicture() { console.log("Fetching random post..."); - const { queryIndex, post } = await e621.getRandomPost(); + const queryIndex = Math.floor(Math.random() * config.e621.queries.length); + const query = config.e621.queries[queryIndex]; + const post = await e621.getRandomPost(query); console.log(`Got ${post.id} via query ${queryIndex}`); @@ -27,9 +29,9 @@ async function postRandomPicture() { } async function postSpecificPicture(id: number) { - console.log("Fetching post ${id}..."); + console.log(`Fetching post ${id}...`); - const post = await e621.getPost(id); + const post = await e621.getPostById(id); console.log(`Got ${post.id}`); -- cgit v1.2.3-70-g09d2