File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 1
1
import useSWR from "swr" ;
2
+ import wretch from "wretch" ;
2
3
import Image from "next/image" ;
3
4
4
5
interface Props {
@@ -10,7 +11,10 @@ export const TokenImage = (props: Props) => {
10
11
const { symbol = "" , size = 20 } = props ;
11
12
const { data } = useSWR (
12
13
`https://api-preview.mochi.console.so/api/v1/product-metadata/emoji?codes=${ symbol } ` ,
13
- ( url ) => fetch ( url ) . then ( ( res ) => res . json ( ) ) ,
14
+ ( url ) =>
15
+ wretch ( url )
16
+ . get ( )
17
+ . json ( ( res ) => res . data ) ,
14
18
{
15
19
revalidateIfStale : false ,
16
20
revalidateOnFocus : false ,
@@ -21,7 +25,7 @@ export const TokenImage = (props: Props) => {
21
25
return (
22
26
< Image
23
27
src = {
24
- data ?. data [ 0 ] ?. emoji_url ||
28
+ data ?. [ 0 ] ?. emoji_url ||
25
29
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk8AEAAFIATgDK/mEAAAAASUVORK5CYII="
26
30
}
27
31
alt = { symbol }
Original file line number Diff line number Diff line change 1
1
import { create } from "zustand" ;
2
+ import wretch from "wretch" ;
2
3
3
4
export interface Chain {
4
5
id ?: number ;
@@ -52,10 +53,11 @@ const initialState: State = {
52
53
export const useTokenStaking = create < State & Action > ( ( set , get ) => ( {
53
54
...initialState ,
54
55
fetchStakingPools : async ( ) => {
55
- const response = await fetch (
56
+ const res = await wretch (
56
57
"https://api-preview.tono.console.so/api/v1/guilds/462663954813157376/community/token/staking"
57
- ) ;
58
- const json = await response . json ( ) ;
59
- set ( { stakingPools : json ?. data ?. data || [ ] } ) ;
58
+ )
59
+ . get ( )
60
+ . json ( ( res ) => res ?. data ?. data ) ;
61
+ set ( { stakingPools : res || [ ] } ) ;
60
62
} ,
61
63
} ) ) ;
You can’t perform that action at this time.
0 commit comments