From 7a049b1d360a2d18f5e45c1e10322e53c301c0bd Mon Sep 17 00:00:00 2001
From: NGUYEN DINH Quoc-Huy <quochuy@gmail.com>
Date: Tue, 22 Sep 2020 23:05:42 +1000
Subject: [PATCH] Defaulting post_voting_power to 0 if missing from API
 response

---
 src/app/utils/steemApi.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/app/utils/steemApi.js b/src/app/utils/steemApi.js
index 0102f98ad..5169d5afd 100644
--- a/src/app/utils/steemApi.js
+++ b/src/app/utils/steemApi.js
@@ -1,4 +1,5 @@
 import { api } from '@hiveio/hive-js';
+import _ from 'lodash';
 import { ifHive } from 'app/utils/Community';
 import stateCleaner from 'app/redux/stateCleaner';
 import {
@@ -28,8 +29,11 @@ export function getHivePowerForUser(account) {
                 'database_api.find_accounts',
                 { accounts: [account] }
             );
-            const post_voting_power =
-                fullAccounts['accounts'][0]['post_voting_power'];
+            const post_voting_power = _.get(
+                fullAccounts,
+                'accounts[0].post_voting_power',
+                0
+            );
             /**
              * This magic number is coming from
              * https://gitlab.syncad.com/hive/hivemind/-/blame/d2d5ef25107908db09438da5ee3da9d6fcb976bc/hive/server/bridge_api/objects.py
-- 
GitLab