@@ -202,28 +202,36 @@ const MapCTFCaps = ({mapId, mode, perPage, page}) =>{
202
202
203
203
const capMode = ( mode === 0 ) ? "solo" : "assist" ;
204
204
205
- const req = await fetch ( "/api/ctf" , {
206
- "signal" : controller . signal ,
207
- "headers" : { "Content-type" : "application/json" } ,
208
- "method" : "POST" ,
209
- "body" : JSON . stringify ( {
210
- "mode" : "map-caps" ,
211
- "mapId" : mapId ,
212
- "perPage" : perPage ,
213
- "page" : page ,
214
- "capType" : capMode ,
215
- } )
216
- } ) ;
217
-
218
- const res = await req . json ( ) ;
219
-
220
- if ( res . error !== undefined ) {
221
- dispatch ( { "type" : "error" , "errorMessage" : res . error } ) ;
222
- return ;
205
+ try {
206
+
207
+ const req = await fetch ( "/api/ctf" , {
208
+ "signal" : controller . signal ,
209
+ "headers" : { "Content-type" : "application/json" } ,
210
+ "method" : "POST" ,
211
+ "body" : JSON . stringify ( {
212
+ "mode" : "map-caps" ,
213
+ "mapId" : mapId ,
214
+ "perPage" : perPage ,
215
+ "page" : page ,
216
+ "capType" : capMode ,
217
+ } )
218
+ } ) ;
219
+
220
+ const res = await req . json ( ) ;
221
+
222
+ if ( res . error !== undefined ) {
223
+ dispatch ( { "type" : "error" , "errorMessage" : res . error } ) ;
224
+ return ;
225
+ }
226
+
227
+ dispatch ( { "type" : "loaded" , "caps" : res . caps , "players" : res . players , "totalCaps" : res . totalCaps } ) ;
228
+
229
+ } catch ( err ) {
230
+
231
+ if ( err . name === "AbortError" ) return ;
232
+ dispatch ( { "type" : "error" , "errorMessage" : err . toString ( ) } ) ;
223
233
}
224
234
225
- dispatch ( { "type" : "loaded" , "caps" : res . caps , "players" : res . players , "totalCaps" : res . totalCaps } ) ;
226
-
227
235
}
228
236
229
237
loadData ( ) ;
0 commit comments