1.2.0 • Published 4 years ago

@elchologamer/random-reddit v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

reddit-post

Get random Reddit posts from a specified Subreddit extremely simple! Here's how it works:

Installation

npm i @elchologamer/random-reddit --save

Options

You can use any of these options when getting a post:

  • searchLimit -> number: Number of posts to fetch for selection. (If this is too big, the request will have a significant delay)
  • imageOnly -> boolean: Determines if the post must come with an image
  • allowNSFW -> boolean: Determines if NSFW posts are allowed

JavaScript usage

const randomReddit = require('@elchologamer/random-reddit');

// Create options
let options = {
  imageOnly: true,
  allowNSFW: false,
};

/*
Get a random post from r/memes, 
returning only an image, and not
allowing NSFW posts
*/
randomReddit('memes', options)
  .then((post) => {
    console.log(`Post found: ${post.title}`);
  })
  .catch((err) => {
    console.error(err);
  });

TypeScript usage

import randomReddit, { SearchOptions } from '@elchologamer/random-reddit';

// Create options
let options: SearchOptions = {
  imageOnly: true,
  allowNSFW: false,
};

/*
Get a random post from r/memes, 
returning only an image, and not
allowing NSFW posts
*/
getPost('memes', options)
  .then((post) => {
    console.log(`Post found: ${post.title}`);
  })
  .catch((err) => {
    console.error(err);
  });
1.2.0

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago