@@ -21,6 +21,7 @@ import { AvailablePlatforms } from '..'
21
21
import fallbackImage from 'frontend/assets/heroic_card.jpg'
22
22
import ContextProvider from 'frontend/state/ContextProvider'
23
23
import classNames from 'classnames'
24
+ import axios from 'axios'
24
25
25
26
type Props = {
26
27
availablePlatforms : AvailablePlatforms
@@ -50,7 +51,7 @@ export default function SideloadDialog({
50
51
t ( 'sideload.field.title' , 'Title' )
51
52
)
52
53
const [ selectedExe , setSelectedExe ] = useState ( '' )
53
- const [ imageUrl , setImageUrl ] = useState ( fallbackImage )
54
+ const [ imageUrl , setImageUrl ] = useState ( '' )
54
55
const [ searching , setSearching ] = useState ( false )
55
56
const [ app_name , setApp_name ] = useState ( appName ?? '' )
56
57
const [ runningSetup , setRunningSetup ] = useState ( false )
@@ -115,20 +116,24 @@ export default function SideloadDialog({
115
116
setSearching ( true )
116
117
117
118
try {
118
- const res = await fetch (
119
- `https://steamgrid.usebottles.com/api/search/${ title } `
119
+ const response = await axios . get (
120
+ `https://steamgrid.usebottles.com/api/search/${ title } ` ,
121
+ { timeout : 3500 }
120
122
)
121
- if ( res . status === 200 ) {
122
- const steamGridImage = ( await res . json ( ) ) as string
123
+
124
+ if ( response . status === 200 ) {
125
+ const steamGridImage = response . data as string
126
+
123
127
if ( steamGridImage && steamGridImage . startsWith ( 'http' ) ) {
124
128
setImageUrl ( steamGridImage )
125
129
}
126
- setSearching ( false )
130
+ } else {
131
+ throw new Error ( 'Fetch failed' )
127
132
}
128
133
} catch ( error ) {
129
- console . error ( 'Error when getting image from SteamGridDB' )
130
- setSearching ( false )
131
134
window . api . logError ( `${ error } ` )
135
+ } finally {
136
+ setSearching ( false )
132
137
}
133
138
}
134
139
0 commit comments