1.5.1 • Published 5 years ago

reddit-fetch v1.5.1

Weekly downloads
123
License
MIT
Repository
github
Last release
5 years ago

reddit-fetch

Downloads Minified size Version License

NPM

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

FIELDTYPEDESCRIPTIONDEFAULT
subredditstringan existing reddit communityN/A
sort?stringa valid reddit sorting option'top'
allowNSFW?booleanwhether or not the returned post can be marked as NSFWfalse
allowModPost?booleanwhether or not the returned post can be distinguished as a mod postfalse
allowCrossPost?booleanwhether or not the returned post can be a crosspostfalse
allowVideo?booleanwhether or not the returned post can be a videofalse

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 :)

1.5.1

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago

1.2.0

5 years ago

1.2.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago