How to list following and un-following with Steem-js API
Repository
e.g. https://github.com/steemit/steem-js

What Will I Learn?
- You will learn that how to get a list of following and un-following with steem-js
Requirements
State the requirements the user needs in order to follow this tutorial.
- Basic knowledge of HTML / CSS / Javascript
Difficulty
- Intermediate
Tutorial Contents
This tutorial will teach you how to get the list of followings from a certain steemit account using this code...
steem.api.getFollowing(follower, startFollowing, followType, limit, function(err, result) {
console.log(err, result);
});
Let's Begin
I will explain the above code step by step...
Inside
steem.api.getFollowing
the first argument isfollower
:follower
is the account for which you want to get followings, For e.g. if I want to see as "genievot" how much people I am following, then inside the first argument we add "genievot" with quotes because the first argument accept string. You can also give values in variables like ` let follower = "genievot";
2nd Argument:
startFollowing
is used to see your followings from any index, If you want to see from start then simply use0
for the argument. It means start from the 0'th index or 1st value.
3rd Argument:
followType
is used to find for what type of followings you want to get,followType
can be"blog"
ornull
. If you want to putblog
then use quotes like this"blog"
because it accepts a string.
4th Argument:
limit
is used to get your followings in a list up to a certain limit. Max limit is1000
, any greater value than 1000 will return an error. You can have the lowest limit as well.
Let's Implement this method.
I will use this code but you can change the method parameters accordingly. goto http://steemoc.jaeven.com and use this code. [Steemoc not create by @genievot, it's another developer's project, found in steem projects website.]
let follower = "utopian-io";
let startFollowing = 0;
let followType = 'blog';
let limit = 1000;
steem.api.getFollowing(follower, startFollowing, followType, limit, function(err, result) {
console.log(err, result);
});
General info: You will see the list of followings for your whole life if you followed someone once, even after unfollowing it you will see that guy over the following list due to blockchain nature. So what makes the difference in following and un-following? It's
what[]
key in JSON.what
include the data of your following or un-following. That's why we can use"blog"
ornull
forfollowType
argument, It means to either print Following of"blog"
or un-following meansnull
.
Proof of Work Done
https://github.com/genievot/SteemUnfollow - used this API method in this open source project.
Thank you for your contribution.
Below is our feedback per reviewing your work:
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Thank you for your review, @mcfarhat!
So far this week you've reviewed 1 contributions. Keep up the good work!
Thanks, @mcfarhat for judging this post with your expert view, As I just started to work for utopian-io contribution I am learning from mods like you pointing me out on my mistakes and helping me to solve them.
Some of the things I would like to discuss.
null
, all over the git hub pages, people use this method withnull
, so I demonstrated here. I was explainingwhat
concept differently. So they can combine what I trying to say.So in the tutorial, I also explain what changes happen when you unfollow someone and what not. So probably 2 concepts are covered in this tutorial very well.
Hello @genievot, I expected more than console logging the response tbh. The usage of follow API is already clearly documented in Steem Developers docs, instead you could have created an infinite scroll type of html ui to show the incoming data on web page.
I appreciate your suggestion but my motive was to clearly define the working of steem API method. I didn't find any proper documentation for this method except the method is written over docs in steem-js docs GitHub. If you want a tutorial for Calling JSON to show data over HTML than let me know and I will cover that in another tutorial.
Hi @genievot! We are @steem-ua, a new Steem dApp, computing UserAuthority for all accounts on Steem. We are currently in test modus upvoting quality Utopian-io contributions! Nice work!
Thank you.
Hey @genievot
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!