From 8f31e5c930074b168f010aae6f7907cbdd4dffc5 Mon Sep 17 00:00:00 2001 From: daniel-vahn Date: Fri, 26 Apr 2024 09:55:24 +0200 Subject: [PATCH] Refactor getAccountAndBalance to getAccountData --- src/App.tsx | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2512eea..3cfae61 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -66,10 +66,10 @@ function App() { const [account, setAccount] = useState(null); const [balance, setBalance] = useState(null); - const getAccountAndBalance = async () => { + const getAccountData = async () => { const providerId = window.localStorage.getItem('providerId'); await axios - .get(BRIDGE_URL + '/accounts/' + providerId, { + .get(BRIDGE_URL + '/account/' + providerId, { withCredentials: true, headers: { 'Content-Type': 'application/json', @@ -79,20 +79,9 @@ function App() { .then((response) => { console.log(response.data.accounts[0]); - setAccount(response.data.accounts[0]); - }); - - await axios - .get(BRIDGE_URL + '/balance/' + account, { - withCredentials: true, - headers: { - 'Content-Type': 'application/json', - 'ngrok-skip-browser-warning': 'true', - }, - }) - .then((response) => { - console.log(response.data.balance); - setBalance(response.data.balance); + const { account, balance } = response.data; + setAccount(account); + setBalance(balance); }); }; @@ -126,7 +115,7 @@ function App() { WebApp.MainButton.textColor = '#ffffff'; WebApp.MainButton.onClick(openWallet); - getAccountAndBalance(); + getAccountData(); } if (view === View.WALLET) { WebApp.MainButton.show();