@ecency/sdk 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -402,7 +402,11 @@ function getAccountFullQueryOptions(username) {
402
402
  if (!response[0]) {
403
403
  throw new Error("[SDK] No account with given username");
404
404
  }
405
- const profile = JSON.parse(response[0].posting_json_metadata).profile;
405
+ let profile = {};
406
+ try {
407
+ profile = JSON.parse(response[0].posting_json_metadata).profile;
408
+ } catch (e) {
409
+ }
406
410
  let follow_stats;
407
411
  try {
408
412
  follow_stats = await CONFIG.hiveClient.database.call(
@@ -411,11 +415,16 @@ function getAccountFullQueryOptions(username) {
411
415
  );
412
416
  } catch (e) {
413
417
  }
414
- const reputation = await CONFIG.hiveClient.call(
415
- "condenser_api",
416
- "get_account_reputations",
417
- [username, 1]
418
- );
418
+ let reputationValue = 0;
419
+ try {
420
+ const reputation = await CONFIG.hiveClient.call(
421
+ "condenser_api",
422
+ "get_account_reputations",
423
+ [username, 1]
424
+ );
425
+ reputationValue = reputation[0]?.reputation ?? 0;
426
+ } catch (e) {
427
+ }
419
428
  return {
420
429
  name: response[0].name,
421
430
  owner: response[0].owner,
@@ -455,11 +464,8 @@ function getAccountFullQueryOptions(username) {
455
464
  voting_power: response[0].voting_power,
456
465
  downvote_manabar: response[0].downvote_manabar,
457
466
  follow_stats,
458
- reputation: reputation[0].reputation,
459
- profile: {
460
- ...profile,
461
- reputation: reputation[0].reputation
462
- }
467
+ reputation: reputationValue,
468
+ profile
463
469
  };
464
470
  },
465
471
  enabled: !!username,