Skip to content

Commit

Permalink
update: handle error fetchValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
ninhxuanhuan committed Dec 5, 2024
1 parent 66a15b4 commit af9193a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/pages/UniversalSwap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,15 @@ const Swap: React.FC = () => {

useEffect(() => {
async function fetchValidator() {
const res = await fetch(`https://api.scan.orai.io/v1/validators?page_id=1&moniker=megaorai2`).then((data) =>
data.json()
);
const appOrai = res.data[0].apr * 1.05;
setAprOrai(appOrai);
try {
const res = await fetch(`https://api.scan.orai.io/v1/validators?page_id=1&moniker=megaorai2`).then((data) =>
data.json()
);
const appOrai = res?.data[0]?.apr * 1.05;
setAprOrai(appOrai);
} catch (error) {
console.log({ error });
}
}
fetchValidator();
}, []);
Expand Down

0 comments on commit af9193a

Please sign in to comment.