Introduction
reddit-posts
is a package to get a random reddit post data. In addition, it makes for programmer an easier work.
NOTE: This package is not made by reddit. It is just unofficial package to get random post data. It is legal to use.
Installing package
This is recommended command to execute in terminal to install package:
npm i reddit-posts@latest
Any command that install package is okay to run.
Requirements
minimum requirements:
- Having Node.js v12 or newer versions installed in your device.
maximum requirements:
- Having Node.js v16 or newer versions installed in your device.
Example
Here is an example for this package:
const RandomReddit = require("reddit-posts");
RandomReddit.GetRandompost("aww").then(async (data) => {
console.log(data.title);
console.log(data.SubredditPrefix);
console.log(data.IsNSFW);
console.log(data.UpVotes);
console.log(data.ImageURL);
console.log(data.selftext);
console.log(data.url);
console.log(data.CommentsNum)
console.log(data.Author);
console.log(data.DownVotes);
});
If you are using this package in async function. I recommend you to use await. For example:
const PostData = await RandomReddit.GetRandompost("aww");
console.log(PostData.url);
I wish that example helps.
NOTE: About GetRandomHotpost()
and GetRandomNewpost()
function codes are just same as GetRandompost()
function. You all gotta do is just replacing function names.
What's new in 1.0.4
- Added new values to those functions:
score
. - Added a new function and it is
GetRandomNewpost();