Browse Source

Check currency is defined before accessing node

pull/4/head
Luke Childs 6 years ago
parent
commit
c1f814d68f
  1. 8
      src/lib/calculate-bias.js

8
src/lib/calculate-bias.js

@ -15,13 +15,13 @@ const calculateBias = data => {
// Create correctly ordered array of currency objects
let currencies = [];
for (const symbol of SUPPORTED_CURRENCIES) {
const currency = data.data.scores.find(score => score.node.abbr === symbol).node;
const currency = data.data.scores.find(score => score.node.abbr === symbol);
if (currency) {
currencies.push({
symbol: currency.abbr,
name: currency.name,
influence: currency.score
symbol: currency.node.abbr,
name: currency.node.name,
influence: currency.node.score
});
}
}

Loading…
Cancel
Save