Skip to content

Commit

Permalink
apibase wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
feruzm committed Oct 23, 2023
1 parent 3700e19 commit 25db10e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/common/api/hive-engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import HiveEngineToken from "../helper/hive-engine-wallet";
import { TransactionConfirmation } from "@hiveio/dhive";
import { broadcastPostingJSON } from "./operations";
import engine from "../constants/engine.json";
import { apiBase } from "./helper";

interface TokenBalance {
symbol: string;
Expand Down Expand Up @@ -58,7 +59,7 @@ export const getTokenBalances = (account: string): Promise<TokenBalance[]> => {
};

return axios
.post(engine.API, data, {
.post(apiBase(engine.API), data, {
headers: { "Content-type": "application/json", "User-Agent": "Ecency-apps 1.0" }
})
.then((r) => r.data.result)
Expand All @@ -82,7 +83,7 @@ const getTokens = (tokens: string[]): Promise<Token[]> => {
};

return axios
.post(engine.API, data, {
.post(apiBase(engine.API), data, {
headers: { "Content-type": "application/json", "User-Agent": "Ecency-apps 1.0" }
})
.then((r) => r.data.result)
Expand All @@ -108,7 +109,7 @@ export const getHiveEngineTokenBalances = async (account: string): Promise<HiveE
export const getUnclaimedRewards = async (account: string): Promise<TokenStatus[]> => {
return (
axios
.get(`${engine.rewardAPI}/${account}?hive=1`)
.get(apiBase(`${engine.rewardAPI}/${account}?hive=1`))
.then((r) => r.data)
.then((r) => Object.values(r))
.then((r) => r.filter((t) => (t as TokenStatus).pending_token > 0)) as any
Expand Down Expand Up @@ -169,7 +170,7 @@ export const getMetrics: any = async (symbol?: any, account?: any) => {
// })
// return result;
return axios
.post(engine.API, data, {
.post(apiBase(engine.API), data, {
headers: { "Content-type": "application/json", "User-Agent": "Ecency-apps 1.0" }
})
.then((r) => r.data.result)
Expand All @@ -179,7 +180,7 @@ export const getMetrics: any = async (symbol?: any, account?: any) => {
};

export const getMarketData = async (symbol: any) => {
const { data: history } = await axios.get(`${engine.chartAPI}`, {
const { data: history } = await axios.get(apiBase(`${engine.chartAPI}`), {
params: { symbol, interval: "daily" }
});
return history;
Expand Down

0 comments on commit 25db10e

Please sign in to comment.