File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -6,12 +6,19 @@ function App() {
6
6
const [ planet , setPlanet ] = useState ( null )
7
7
8
8
const handleRestCall = async ( ) => {
9
- const temp = await getTemp ( ) ;
10
- const imgRes = await fetch ( `http://sömi-weather.ch/api/get-the-star-wars-planets-mapping-for-the-current-temperature-completely-and-utterly-accurate?temp=${ temp } ` )
11
- console . log ( imgRes ) ;
12
- const imgJson = await imgRes . json ( ) ;
13
- console . log ( imgJson ) ;
14
- setPlanet ( imgJson ) ;
9
+ $ ( "body" ) . css ( "cursor" , "progress" ) ;
10
+ try {
11
+ const temp = await getTemp ( ) ;
12
+ const imgRes = await fetch ( `http://sömi-weather.ch/api/get-the-star-wars-planets-mapping-for-the-current-temperature-completely-and-utterly-accurate?temp=${ temp } ` )
13
+ console . log ( imgRes ) ;
14
+ const imgJson = await imgRes . json ( ) ;
15
+ console . log ( imgJson ) ;
16
+ setPlanet ( imgJson ) ;
17
+ } catch ( error ) {
18
+ console . log ( "error" )
19
+ } finally {
20
+ $ ( "body" ) . css ( "cursor" , "default" ) ;
21
+ }
15
22
} ;
16
23
17
24
const getTemp = async ( ) => {
@@ -84,7 +91,7 @@ export function Planet({ planet }) {
84
91
return (
85
92
< >
86
93
< h1 > Name: { name } </ h1 >
87
- < img src = { image } alt = "Star Wars Planet" />
94
+ < img src = { image } alt = "Star Wars Planet" style = "width: 50%;" />
88
95
</ >
89
96
) ;
90
97
}
You can’t perform that action at this time.
0 commit comments