A simple, fast wrapper for fetching information from reddit posts.
This package is deprecated, and I'm no longer fixing bugs. Please use justreddit instead.
You can fork the project if you wish to develop it further.
const redditFetch = require('reddit-fetch');
redditFetch({
subreddit: 'all',
sort: 'hot',
allowNSFW: true,
allowModPost: true,
allowCrossPost: true,
allowVideo: true
}).then(post => {
console.table(post);
});
FIELD | TYPE | DESCRIPTION | DEFAULT |
---|---|---|---|
subreddit | string | an existing reddit community | N/A |
sort | ?string | a valid reddit sorting option | 'top' |
allowNSFW | ?boolean | whether or not the returned post can be marked as NSFW | false |
allowModPost | ?boolean | whether or not the returned post can be distinguished as a mod post | false |
allowCrossPost | ?boolean | whether or not the returned post can be a crosspost | false |
allowVideo | ?boolean | whether or not the returned post can be a video | false |
- Returns a promise that resolves to a JSON object (
Promise<object>
). - By default, the Reddit JSON API should not return any removed or deleted posts.
- Unhandled rejections can be caught and handled:
...
}).then(post => {
// Use post data
}).catch(e => {
console.error(`Promise rejection: ${e}`);
});
- NPM Package
- Reddit API Documentation
- Handling promise rejections
- Using promises
- Reasons to switch to Deno
- JavaScript property accessors
Made with <3 by Lily :)