File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -212,13 +212,29 @@ <h3 style="text-align: center; margin-bottom: 0.125rem">
212212 async function saveConfig ( ) {
213213 const config = { } ;
214214 const ids = [ { CONFIG_IDS } ] ;
215- ids . forEach ( ( id ) => ( config [ id ] = getValue ( id ) ) ) ;
216- await fetch ( "/config" , {
217- method : "POST" ,
218- headers : { "Content-Type" : "application/json" } ,
219- body : JSON . stringify ( config ) ,
215+
216+ ids . forEach ( ( id ) => {
217+ config [ id ] = getValue ( id ) ;
220218 } ) ;
221- alert ( "Configuration saved!" ) ;
219+
220+ try {
221+ const response = await fetch ( "/config" , {
222+ method : "POST" ,
223+ headers : { "Content-Type" : "application/json" } ,
224+ body : JSON . stringify ( config ) ,
225+ } ) ;
226+
227+ if ( ! response . ok ) {
228+ // Try to get error message from the response
229+ const errorText = await response . text ( ) ;
230+ throw new Error ( `Error ${ response . status } : ${ errorText } ` ) ;
231+ }
232+
233+ alert ( "✅ Configuration saved successfully!" ) ;
234+ } catch ( error ) {
235+ console . error ( "❌ Failed to save configuration:" , error ) ;
236+ alert ( `❌ Failed to save configuration:\n${ error . message } ` ) ;
237+ }
222238 }
223239
224240 loadConfig ( ) ;
You can’t perform that action at this time.
0 commit comments