@@ -413,21 +413,16 @@ class Participation extends AsyncComponent<unknown, ParticipationState> {
413413 */
414414 private async fetchEvents ( ) : Promise < void > {
415415 try {
416- const response = await FetchHelper . json < unknown , {
417- data ?: IParticipationEvents ;
418- error ?: {
419- message : string ;
420- } ;
421- } > (
416+ const response = await FetchHelper . json < unknown , IParticipationEvents > (
422417 `${ window . location . protocol } //${ window . location . host } ` ,
423418 "/api/plugins/participation/v1/events" ,
424419 "get" ,
425420 undefined ,
426421 Participation . buildAuthHeaders ( ) ) ;
427422
428- if ( response ?. data ?. eventIds ) {
423+ if ( response ?. eventIds ) {
429424 this . setState ( {
430- eventIds : response . data . eventIds
425+ eventIds : response . eventIds
431426 } ) ;
432427 } else {
433428 console . log ( response . error ) ;
@@ -443,23 +438,18 @@ class Participation extends AsyncComponent<unknown, ParticipationState> {
443438 */
444439 private async fetchEventInfo ( id : string ) : Promise < void > {
445440 try {
446- const response = await FetchHelper . json < unknown , {
447- data ?: IParticipationEventInfo ;
448- error ?: {
449- message : string ;
450- } ;
451- } > (
441+ const response = await FetchHelper . json < unknown , IParticipationEventInfo > (
452442 `${ window . location . protocol } //${ window . location . host } ` ,
453443 `/api/plugins/participation/v1/events/${ id } ` ,
454444 "get" ,
455445 undefined ,
456446 Participation . buildAuthHeaders ( ) ) ;
457447
458- if ( response . data ) {
448+ if ( ! response ?. error ) {
459449 this . setState ( prevState => ( {
460450 events : {
461451 ...prevState . events ,
462- [ id ] : response . data as IParticipationEventInfo
452+ [ id ] : response
463453 }
464454 } ) ) ;
465455 } else {
@@ -476,27 +466,22 @@ class Participation extends AsyncComponent<unknown, ParticipationState> {
476466 */
477467 private async fetchEventStatus ( id : string ) : Promise < void > {
478468 try {
479- const response = await FetchHelper . json < unknown , {
480- data ?: IParticipationEventStatus ;
481- error ?: {
482- message : string ;
483- } ;
484- } > (
469+ const response = await FetchHelper . json < unknown , IParticipationEventStatus > (
485470 `${ window . location . protocol } //${ window . location . host } ` ,
486471 `/api/plugins/participation/v1/events/${ id } /status` ,
487472 "get" ,
488473 undefined ,
489474 Participation . buildAuthHeaders ( ) ) ;
490475
491- if ( response . data ) {
476+ if ( ! response ?. error ) {
492477 if ( this . state . events [ id ] ) {
493478 this . setState ( prevState => ( {
494479 ...prevState ,
495480 events : {
496481 ...prevState . events ,
497482 [ id ] : {
498483 ...prevState . events [ id ] ,
499- status : response . data
484+ status : response
500485 }
501486 }
502487 } ) ) ;
@@ -546,20 +531,15 @@ class Participation extends AsyncComponent<unknown, ParticipationState> {
546531 dialogStatus : "Adding event, please wait..."
547532 } , async ( ) => {
548533 try {
549- const response = await FetchHelper . json < unknown , {
550- data ?: IParticipationEvent ;
551- error ?: {
552- message : string ;
553- } ;
554- } > (
534+ const response = await FetchHelper . json < unknown , IParticipationEvent > (
555535 `${ window . location . protocol } //${ window . location . host } ` ,
556536 "/api/plugins/participation/v1/admin/events" ,
557537 "post" ,
558538 eventInfo ,
559539 Participation . buildAuthHeaders ( ) ) ;
560540
561- if ( response . data ) {
562- const id = response . data . eventId ;
541+ if ( response . eventId ) {
542+ const id = response . eventId ;
563543 this . setState ( prevState => ( {
564544 eventIds : [
565545 id ,
@@ -640,30 +620,20 @@ class Participation extends AsyncComponent<unknown, ParticipationState> {
640620 */
641621 private async fetchEventJsonConfig ( url : URL ) : Promise < IParticipationEventInfo | undefined > {
642622 try {
643- const response = await FetchHelper . json < unknown , {
644- data ?: IParticipationEventInfo ;
645- error ?: {
646- message : string ;
647- } ;
648- } > (
623+ const response = await FetchHelper . json < unknown , IParticipationEventInfo > (
649624 url . origin ,
650625 url . pathname ,
651626 "get" ) ;
652627
653- return ( response . data ) ? response . data : response as IParticipationEventInfo ;
628+ return response ;
654629 } catch {
655630 try {
656- const response = await FetchHelper . text < unknown , {
657- data ?: IParticipationEventInfo ;
658- error ?: {
659- message : string ;
660- } ;
661- } > (
631+ const response = await FetchHelper . text < unknown , IParticipationEventInfo > (
662632 url . origin ,
663633 url . pathname ,
664634 "get" ) ;
665635
666- return ( response . data ) ? response . data : response as IParticipationEventInfo ;
636+ return response ;
667637 } catch ( error ) {
668638 if ( error instanceof Error ) {
669639 this . setState ( {
0 commit comments