@@ -130,12 +130,15 @@ export class HandleReceivedObservation extends WorkflowEntrypoint<
130130 . map ( ( b ) => b . toString ( 16 ) . padStart ( 2 , "0" ) )
131131 . join ( "" ) ,
132132 } ) ;
133- return await fetch (
133+ const response = await fetch (
134134 `https://www.windguru.cz/upload/api.php?${ params . toString ( ) } ` ,
135135 {
136136 method : "GET" ,
137137 }
138138 ) . then ( ( response ) => response . text ( ) ) ;
139+ if ( response !== "OK" ) {
140+ throw new Error ( `Windguru upload failed: ${ response } ` ) ;
141+ }
139142 }
140143 ) ;
141144 await step . do (
@@ -169,14 +172,19 @@ export class HandleReceivedObservation extends WorkflowEntrypoint<
169172 //windgustmph: data.data.windGust.toString(), // real number [mph]; current wind gust (alternative to gust)
170173 dewpoint : data . data . dewPoint . toString ( ) , // real number [°C];
171174 precip : data . data . lastHourRain . toString ( ) , // real number [mm]; precipitation over the past hour
172- uv : data . data . uv . toString ( ) , //number [index];
173175 } ) ;
174- return await fetch (
176+ const response = await fetch (
175177 `https://stations.windy.com/pws/update/${ WINDY_API_KEY } ?${ params . toString ( ) } ` ,
176178 {
177179 method : "GET" ,
178180 }
179- ) . then ( ( response ) => response . text ( ) ) ;
181+ ) . then ( ( response ) => response . json ( ) ) ;
182+ if (
183+ ! response ||
184+ typeof response !== "object" ||
185+ Object . keys ( response ) . length !== 0
186+ )
187+ throw new Error ( `Windy upload failed: ${ JSON . stringify ( response ) } ` ) ;
180188 }
181189 ) ;
182190 await step . do (
@@ -218,12 +226,20 @@ export class HandleReceivedObservation extends WorkflowEntrypoint<
218226 //windgustmph: data.data.windGust.toString(), // real number [mph]; current wind gust (alternative to gust)
219227 //windgustdir: data.data.windGustDirection.toString(), // integer number [deg]; instantaneous wind direction
220228 } ) ;
221- return await fetch (
229+ const response = await fetch (
222230 `http://wow.metoffice.gov.uk/automaticreading?${ params . toString ( ) } ` ,
223231 {
224232 method : "GET" ,
225233 }
226- ) . then ( ( response ) => response . text ( ) ) ;
234+ ) . then ( ( response ) => response . json ( ) ) ;
235+ if (
236+ ! response ||
237+ typeof response !== "object" ||
238+ Object . keys ( response ) . length !== 0
239+ )
240+ throw new Error (
241+ `Met Office upload failed: ${ JSON . stringify ( response ) } `
242+ ) ;
227243 }
228244 ) ;
229245 }
0 commit comments