Comparing version 1.0.1 to 1.0.2
25
index.js
@@ -52,2 +52,27 @@ const needle = require('needle'); | ||
}) | ||
} | ||
exports.search = (query,cb) => { | ||
if (!query) { | ||
console.error("query param required"); | ||
return false; | ||
} | ||
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/search.json?q="+encodeURI(query)+"&limit=100",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.1", | ||
"version": "1.0.2", | ||
"description": "reddit api without any authentication!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
3103
84