reddit-fetch
A simple, fast wrapper for fetching information from reddit posts.
Usage & Example
const redditFetch = require('reddit-fetch');
redditFetch({
subreddit: 'all',
sort: 'hot',
allowNSFW: true,
allowModPost: true,
allowCrossPost: true,
allowVideo: true
}).then(post => {
console.table(post);
});
Options
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 |
Function details
- 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}`);
});
Additional Links
Made with <3 by Lily :)