From 846c0444602a74994de55c3cc3ad1b78c0fed9ba Mon Sep 17 00:00:00 2001
From: adcpm <fabien@adcpm.com>
Date: Thu, 18 Aug 2016 13:04:25 +0700
Subject: [PATCH] - Update test.js with examples include getFollowing method

---
 .gitignore   |  1 +
 dev.js       | 22 ++++++++++++++++++++++
 lib/steem.js | 18 ++++++++----------
 package.json |  2 +-
 test.js      | 35 +++++++++++++++++------------------
 5 files changed, 49 insertions(+), 29 deletions(-)
 create mode 100644 dev.js

diff --git a/.gitignore b/.gitignore
index 7785cee..2621e29 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@ scr
 .save
 *.css.map
 *.css
+dev.js
 
 # Logs
 logs
diff --git a/dev.js b/dev.js
new file mode 100644
index 0000000..2dbf94b
--- /dev/null
+++ b/dev.js
@@ -0,0 +1,22 @@
+var Steem = require('./lib/steem'),
+	steem = new Steem();
+
+steem.login('******', '****************', function(err, result) {
+	console.log(result);
+	var trx = {
+		expiration: '2016-08-13T05:44:15',
+		extensions: [],
+		operations: [['vote', {
+			voter: '******',
+			author: 'calaber24p',
+			permlink: '5zebtb-the-future-the-possibility-of-capturing-memories-and-reliving-them',
+			weight: 100
+		}]],
+		ref_block_num: 40289,
+		ref_block_prefix: 3483617648,
+		signatures: ['10f7ce6fc9f5bc99fe789af9e464ff62e6b676622611abd22ed332f20649797b13e0ff85a1be1b72bc26f2ba0d4bf6eStef']
+	};
+	steem.broadcastTransaction(trx, function(err, result) {
+		console.log(err, result);
+	});
+});
\ No newline at end of file
diff --git a/lib/steem.js b/lib/steem.js
index 9eb6724..0a627c1 100644
--- a/lib/steem.js
+++ b/lib/steem.js
@@ -51,18 +51,16 @@ Steem.prototype.send = function(api, data, callback) {
 	data.id = data.id || 0;
 	data.params = data.params || [];
 	this.open(function(){
-		this.getApi(api, function(err, apiId) {
-			var call = {};
-			call.id = data.id;
-			call.method = 'call';
-			call.params = [apiId, data.method, data.params];
-			this.ws.send(JSON.stringify(call));
-		}.bind(this));
+		var call = {};
+		call.id = data.id;
+		call.method = 'call';
+		call.params = [this.apiIds[api], data.method, data.params];
+		this.ws.send(JSON.stringify(call));
 	}.bind(this));
 
 	this.ws.addEventListener('message', function(msg) {
 		var data = JSON.parse(msg.data);
-		var err = data.error || '';
+		var err = (data.error && data.error.data && data.error.data.stack)? data.error.data.stack : '';
 		callback(err, data);
 	}.bind(this));
 
@@ -861,7 +859,7 @@ Steem.prototype.getFollowers = function(following, startFollower, followType, li
 	this.send('follow_api', {
 		'id': iterator,
 		'method': 'get_followers',
-		'params': [following, startFollower, limit]
+		'params': [following, startFollower, followType, limit]
 	}, function(err, data) {
 		if (iterator == data.id) callback(err, data.result);
 	});
@@ -873,7 +871,7 @@ Steem.prototype.getFollowing = function(follower, startFollowing, followType, li
 	this.send('follow_api', {
 		'id': iterator,
 		'method': 'get_following',
-		'params': [follower, startFollowing, limit]
+		'params': [follower, startFollowing, followType, limit]
 	}, function(err, data) {
 		if (iterator == data.id) callback(err, data.result);
 	});
diff --git a/package.json b/package.json
index eaa4564..37dfdf7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "steem",
-  "version": "0.2.19",
+  "version": "0.2.20",
   "description": "Steem.js the JavaScript API for Steem blockchain",
   "main": "index.js",
   "scripts": {
diff --git a/test.js b/test.js
index 7f734d4..7ac3224 100644
--- a/test.js
+++ b/test.js
@@ -1,23 +1,22 @@
 var Steem = require('./lib/steem'),
 	steem = new Steem();
 
-steem.login('******', '****************', function(err, result) {
-	console.log(result);
-	var trx = {
-		expiration: '2016-08-13T05:44:15',
-		extensions: [],
-		operations: [['vote', {
-			voter: '******',
-			author: 'calaber24p',
-			permlink: '5zebtb-the-future-the-possibility-of-capturing-memories-and-reliving-them',
-			weight: 100
-		}]],
-		ref_block_num: 40289,
-		ref_block_prefix: 3483617648,
-		signatures: ['10f7ce6fc9f5bc99fe789af9e464ff62e6b676622611abd22ed332f20649797b13e0ff85a1be1b72bc26f2ba0d4bf6e']
-	};
-	steem.broadcastTransaction(trx, function(err, result) {
-		console.log(err, result);
-	});
+steem.getAccountCount(function(err, result) {
+	console.log(err, result);
 });
 
+steem.getAccounts(['dan'], function(err, result) {
+	console.log(err, result);
+});
+
+steem.getState('trending/steemit', function(err, result) {
+	console.log(err, result);
+});
+
+steem.getFollowing('ned', 0, 'blog', 10, function(err, result) {
+	console.log(err, result);
+});
+
+steem.getFollowers('dan', 0, 'blog', 10, function(err, result) {
+	console.log(err, result);
+});
\ No newline at end of file
-- 
GitLab