Comparing version 1.0.2 to 1.1.0
52
index.js
@@ -28,4 +28,9 @@ const needle = require('needle'); | ||
if (!post) { | ||
console.error("post param required"); | ||
return false; | ||
var err = { | ||
"err": { | ||
"message": "Post parameter required.", | ||
"code": "noParam" | ||
} | ||
} | ||
return cb(err, null); | ||
} | ||
@@ -57,4 +62,9 @@ var opt = { headers: { | ||
if (!query) { | ||
console.error("query param required"); | ||
return false; | ||
var err = { | ||
"err": { | ||
"message": "Query parameter required.", | ||
"code": "noParam" | ||
} | ||
} | ||
return cb(err, null); | ||
} | ||
@@ -79,2 +89,36 @@ var opt = { headers: { | ||
}) | ||
} | ||
exports.getURL = (url, param, cb) => { | ||
if (!url) { | ||
var err = { | ||
"err": { | ||
"message": "Query parameter required.", | ||
"code": "noParam" | ||
} | ||
} | ||
return cb(err, null); | ||
} | ||
if (!cb) { | ||
var cb = param; | ||
var param = ""; | ||
} | ||
var opt = { headers: { | ||
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", | ||
"Accept-Encoding":"gzip, deflate, br", | ||
"Connection":"keep-alive", | ||
"DNT":"1", | ||
"Host":"www.reddit.com", | ||
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0", | ||
}} | ||
needle.get("https://reddit.com" + url + ".json" + param,opt,async function(err,resp,body) { | ||
if (err) { | ||
var body = null; | ||
cb(err,body); | ||
} else { | ||
var err = null; | ||
var res = body.data.children; | ||
cb(err,res) | ||
} | ||
}) | ||
} |
{ | ||
"name": "redddit", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "reddit api without any authentication!", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"author": "n0rmancodes", | ||
"license": "ISC", | ||
"license": "UNLICENSED", | ||
"bugs": { | ||
@@ -21,0 +21,0 @@ "url": "https://github.com/n0rmancodes/redddit/issues" |
# redddit | ||
Simple Reddit API, no authentication needed! | ||
## sample code | ||
```js | ||
const redddit = require('./index.js'); | ||
redddit.topPosts("videos",function(err,res){ | ||
if (err !== null) { | ||
console.log(err.code) | ||
} else { | ||
var post = res[0].data.permalink; | ||
redddit.getPost(post, function(err,res) { | ||
console.log(res.comments) | ||
}) | ||
} | ||
}); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Explicitly Unlicensed Item
License(Experimental) Something was found which is explicitly marked as unlicensed.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5613
5
127
18
1
1
0