Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const steem = require('steem');
- const username = 'YOUR_USERNAME';
- function getAccountVotes(author) {
- return new Promise((resolve, reject) => {
- steem.api.getAccountVotes(author, (error, result) => {
- if (error) {
- reject(error);
- } else {
- resolve(result);
- }
- });
- });
- }
- function getContent(author, permlink) {
- return new Promise((resolve, reject) => {
- steem.api.getContent(author, permlink, (error, result) => {
- if (error) {
- reject(error);
- } else {
- resolve(result);
- }
- });
- });
- }
- getAccountVotes(username)
- .then(async (votes) => {
- const lastTenVotes = votes.reverse().slice(0, 10);
- const posts = await Promise.all(lastTenVotes.map((vote) => {
- const authorPerm = vote.authorperm.split('/');
- return getContent(authorPerm[0], authorPerm[1]);
- }));
- console.log(posts.map(p => p.title));
- })
- .catch(err => console.log(err));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement