File tree Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Expand file tree Collapse file tree 3 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -121,7 +121,15 @@ export const createQuestionUrl = async (newQuestion: QuestionType) => {
121
121
"Content-Type" : "application/json" ,
122
122
} ,
123
123
body : JSON . stringify ( newQuestion ) ,
124
- } ) . then ( ( res ) => res . json ( ) ) ;
124
+ } )
125
+ . then ( ( res ) => res . json ( ) )
126
+ . then ( ( res ) => {
127
+ console . log ( { res } ) ;
128
+ if ( res . statusMessage ?. type ?. toLowerCase ( ) === "error" ) {
129
+ throw Error ( ) ;
130
+ }
131
+ return res ;
132
+ } ) ;
125
133
} ;
126
134
127
135
export const updateQuestionUrl = async ( updatedQuestion : QuestionType ) => {
@@ -131,7 +139,15 @@ export const updateQuestionUrl = async (updatedQuestion: QuestionType) => {
131
139
"Content-Type" : "application/json" ,
132
140
} ,
133
141
body : JSON . stringify ( updatedQuestion ) ,
134
- } ) . then ( ( res ) => res . json ( ) ) ;
142
+ } )
143
+ . then ( ( res ) => res . json ( ) )
144
+ . then ( ( res ) => {
145
+ console . log ( { res } ) ;
146
+ if ( res . statusMessage ?. type ?. toLowerCase ( ) === "error" ) {
147
+ throw Error ( ) ;
148
+ }
149
+ return res ;
150
+ } ) ;
135
151
} ;
136
152
137
153
export const deleteQuestionUrl = async ( questionId : string ) => {
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ const AddQuestionModal = ({
70
70
onError : ( e ) => {
71
71
api . open ( {
72
72
type : "error" ,
73
- content : "Failed to add question!" ,
73
+ content : "Failed to add question due to same name !" ,
74
74
} ) ;
75
75
} ,
76
76
} ,
@@ -93,7 +93,7 @@ const AddQuestionModal = ({
93
93
} ;
94
94
95
95
console . log ( "Form Submission Data:" , submissionData ) ;
96
- createQuestionMutation . mutate ( submissionData ) ;
96
+ createQuestionMutation && createQuestionMutation . mutate ( submissionData ) ;
97
97
e . currentTarget . reset ( ) ;
98
98
setDefaultValues ( ) ;
99
99
closeModal ( "my_modal_1" ) ;
Original file line number Diff line number Diff line change @@ -69,7 +69,6 @@ const EditQuestionModal = ({
69
69
successCallback ( ) ;
70
70
} ,
71
71
onError : ( e ) => {
72
- console . log ( { e } ) ;
73
72
api . open ( {
74
73
type : "error" ,
75
74
content : "Failed to add question due to having same question name!" ,
You can’t perform that action at this time.
0 commit comments