Skip to content

Commit

Permalink
fix: correct a reward api url in ETH widget IPFS mode
Browse files Browse the repository at this point in the history
  • Loading branch information
solidovic committed Nov 30, 2023
1 parent 04043a4 commit 31596d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion features/rewards/fetchers/requesters/json/backend.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { dynamics } from 'config';

export type BackendQuery = {
address: string;
currency?: string;
Expand All @@ -12,7 +14,11 @@ export const backendRequest = async (query: BackendQuery) => {

Object.entries(query).forEach(([k, v]) => params.append(k, v.toString()));

const requested = await fetch(`/api/rewards?${params.toString()}`);
const apiRewardsPath = `/api/rewards/?${params.toString()}`;
const apiRewardsUrl = dynamics.ipfsMode
? `${dynamics.widgetApiBasePathForIpfs}${apiRewardsPath}`
: apiRewardsPath;
const requested = await fetch(apiRewardsUrl);

if (!requested.ok) {
const responded = await requested.json();
Expand Down
11 changes: 9 additions & 2 deletions features/rewards/hooks/useRewardsDataLoad.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Backend } from 'features/rewards/types';
import { useEffect, useRef } from 'react';
import { Backend } from 'features/rewards/types';
import { dynamics } from 'config';
import { useLidoSWR } from 'shared/hooks';
import { swrAbortableMiddleware } from 'utils';

Expand Down Expand Up @@ -43,8 +44,14 @@ export const useRewardsDataLoad: UseRewardsDataLoad = (props) => {
Object.entries(requestOptions).forEach(([k, v]) =>
params.append(k, v.toString()),
);

const apiRewardsPath = `/api/rewards/?${params.toString()}`;
const apiRewardsUrl = dynamics.ipfsMode
? `${dynamics.widgetApiBasePathForIpfs}${apiRewardsPath}`
: apiRewardsPath;

const { data, ...rest } = useLidoSWR<Backend>(
address ? `/api/rewards?${params.toString()}` : null,
address ? apiRewardsUrl : null,
{
shouldRetryOnError: false,
revalidateOnFocus: false,
Expand Down

0 comments on commit 31596d6

Please sign in to comment.