Skip to content

Commit

Permalink
Fix error handling for account re-authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinschaich committed May 15, 2019
1 parent 8ecd05d commit a6a6d9d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/lib/plaid.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const fetchTransactions = (startDate, endDate, pageSize, offset) => {
return wrapPromise(pMapSeries(accounts, fetchTransactionsForAccount), 'Fetching transactions for accounts')
}

const fetchBalances = () => {
const fetchBalances = options => {
const accounts = getAccountTokens()

const fetchBalanceForAccount = account => {
Expand All @@ -65,12 +65,15 @@ const fetchBalances = () => {
...data,
nickname: account.nickname
}
}).catch(error => {
return { nickname: account.nickname, error: JSON.stringify(error, null, 2) }
}),
`Fetching balance for account ${account.nickname}`
`Fetching balance for account ${account.nickname}`,
options
)
}

return wrapPromise(pMapSeries(accounts, fetchBalanceForAccount), 'Fetching balances for accounts')
return wrapPromise(pMapSeries(accounts, fetchBalanceForAccount), 'Fetching balances for accounts', options)
}

// Exchange token flow - exchange a Link public_token for an API access_token
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ maybeWriteDefaultConfig().then(() => {
switch (process.env.ACCOUNT_PROVIDER) {
case 'plaid':
return require('../lib/plaid')
.fetchBalances()
.fetchBalances({quiet: true})
.then(balances => res.json({ data: balances }))
.catch(error => res.json(error))
default:
Expand Down

0 comments on commit a6a6d9d

Please sign in to comment.