Promise { <pending> }
const fetch = require("node-fetch");
async function gen() {
await fetch( "https://www.reddit.com/r/memes/hot/.json?count=100"
)
.then(res => res.json())
.then(json => {
let postID =
json.data.children[
Math.floor(Math.random() * json.data.children.length)
];
this.result = {
image: postID.data.url,
category: postID.data.link_flair_text,
caption: postID.data.title,
permalink: postID.data.permalink
};
});
return await this.result;
};
console.log(gen())