forked from thislooksfun/snoots
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace getRandomPost() with getRandomPostId()
Reddit designed `/random` using http redirects, which means that getting a random post actually requires _two_ api requests. While this is not the end of the world, it does go against one of the design goals of snoots: minimizing the amount of behind the scenes network requests. Specifically, in this case, there are legitimate reasons (mostly ratelimit related) that a user would need to know that getting a random post takes two requests. Making this changes makes that relationship very explicit. If you want the old single-function behavior back, you can always make a utility function: ```ts async function getRandomPost(client: Client, subreddit?: string) { const postId = await client.subreddits.getRandomPostId(subreddit); return await client.posts.fetch(postId); } ``` or even subclass Client: ```ts class CustomClient extends Client { async getRandomPost(subreddit?: string) { const id = await this.subreddits.getRandomPostId(subreddit); return await this.posts.fetch(id); } } ``` BREAKING CHANGE: `getRandomPost()` replace with `getRandomPostId()`.
- Loading branch information
1 parent
87c9640
commit 8f56359
Showing
3 changed files
with
18 additions
and
21 deletions.
There are no files selected for viewing
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
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
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