Skip to content

Commit

Permalink
feat(dcellar-web-ui): add proxy for bnb price api
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed Dec 3, 2024
1 parent d8d818d commit 2c9247a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/dcellar-web-ui/src/facade/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const getObjectInfoAndBucketQuota = async ({

export const getBnbUsdtExchangeRate = async (): Promise<string> => {
const [res, error] = await get({
url: 'https://bsc-explorer-api.nodereal.io/api/token/getPrice?symbol=bnb',
url: '/api/bnb_price',
customOptions: { needNotify: false },
}).then(resolve, commonFault);

Expand Down
15 changes: 15 additions & 0 deletions apps/dcellar-web-ui/src/pages/api/bnb_price/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';
import { NextApiRequest, NextApiResponse } from 'next';

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const url = `https://bsc-explorer-api.nodereal.io/api/token/getPrice?symbol=bnb`;
try {
const { data } = await axios.get(url);
res.json(data);
} catch (e) {
console.error('bnb_price', e);
res.json({});
}
};

export default handler;

0 comments on commit 2c9247a

Please sign in to comment.