|
|
|
|
@ -3,7 +3,7 @@ const app = express();
|
|
|
|
|
const axios = require('axios');
|
|
|
|
|
const querystring = require('querystring');
|
|
|
|
|
|
|
|
|
|
app.get('/', (req, res)=>{
|
|
|
|
|
app.get('/', async (req, res)=>{
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
grant_type:'password',
|
|
|
|
|
@ -14,25 +14,23 @@ app.get('/', (req, res)=>{
|
|
|
|
|
username: process.env.APPID,
|
|
|
|
|
password: process.env.APPSECRET
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
axios({
|
|
|
|
|
let response = await axios({
|
|
|
|
|
url:'https://www.reddit.com/api/v1/access_token',
|
|
|
|
|
method:'post',
|
|
|
|
|
auth:auth,
|
|
|
|
|
data:querystring.stringify(data)
|
|
|
|
|
}).then((response)=>{
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
|
headers:{
|
|
|
|
|
Authorization: 'bearer '+response.data.access_token
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
axios.get('https://oauth.reddit.com/user/mahuntington/saved?limit=1000', config).then((response)=>{
|
|
|
|
|
response = await axios.get('https://oauth.reddit.com/user/mahuntington/saved?limit=100', config)
|
|
|
|
|
|
|
|
|
|
res.render('all.ejs', { posts: response.data.data.children.filter(post => post.data.subreddit === 'ProgrammerHumor' && post.data.removed_by_category === null)})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
app.listen(3002, ()=>{
|
|
|
|
|
console.log('listening');
|
|
|
|
|
|