Go to file
2021-12-01 20:53:45 +00:00
.github Create FUNDING.yml 2021-05-10 21:50:20 +01:00
.gitlab Update default.md 2021-01-15 18:15:14 +00:00
src Make sortBy optional 2021-12-01 20:53:45 +00:00
.eslintrc Update .eslintrc 2021-01-16 22:16:20 +00:00
.gitignore Replace fetch with got 2021-12-01 20:39:02 +00:00
.gitlab-ci.yml Add aslant to gitlab project ci 2021-01-13 21:08:47 +00:00
.npmignore rewrite in typescript 2021-12-01 20:32:20 +00:00
app.ts rewrite in typescript 2021-12-01 20:32:20 +00:00
CODE_OF_CONDUCT.md Resolve "Create documentation" 2021-01-13 20:38:31 +00:00
CONTRIBUTING.md Resolve "Create documentation" 2021-01-13 20:38:31 +00:00
LICENSE Resolve "Create documentation" 2021-01-13 20:38:31 +00:00
license Resolve "Create documentation" 2021-01-13 20:38:31 +00:00
package.json Replace fetch with got 2021-12-01 20:39:02 +00:00
readme.md Feature/8 return a promise (#5) (#6) 2021-04-12 20:30:59 +01:00
tsconfig.json rewrite in typescript 2021-12-01 20:32:20 +00:00
yarn.lock Replace fetch with got 2021-12-01 20:39:02 +00:00

random-bunny

Get a random image url from a subreddit of your choosing.

Install

$ npm install --save random-bunny

Usage

const { randomBunny } = require('random-bunny');

randomBunny('rabbits', 'new', res => {
    console.log(res.title + ": " + res.url);
});
const { promise } = require('random-bunny');

promise('rabbits', 'new').then((res) => {
    console.log(res.title);
});

API

randomBunny()

Returns a json string for a random post to the callback. Accepts 3 arguments: subreddit, sortby ('new', 'hot', 'top'), callback(res)

The json string which gets returned consists of:

  • archived
  • downs
  • hidden
  • permalink
  • subreddit
  • subredditSubscribers
  • title
  • ups
  • url

promise()

Returns a json string for a random post in a promise. Accepts 2 arguments: subreddit, sortby ('new', 'hot', 'top').

The json string returned in the promise consists of the same above.

Notes

License

MIT © Vylpes