@@ -446,10 +446,13 @@ function apiGet(sub, params, callback, method = "GET") {
446446 * @param {string } sub - The API endpoint to append to the base URL.
447447 * @param {Object } params - An object containing key-value pairs to be sent as query parameters.
448448 * @param {function } callback - A callback function to handle the response.
449- * Receives the response text and status code as arguments.
449+ * Receives the response text and status code as arguments.
450450 * @param {boolean } [isFile=false] - A switch to enable special file upload handling.
451+ * @param {string } [force_method] - The HTTP method to use for the request (e.g., "POST", "PUT").
452+ * If not provided, it will be determined based on the presence of
453+ * a file in the parameters.
451454 */
452- function apiSubmit ( sub , params , callback , isFile = false ) {
455+ function apiSubmit ( sub , params , callback , isFile = false , force_method = undefined ) {
453456 const ajax = createAjax ( callback ) ;
454457 let method ;
455458 let request_uri ;
@@ -466,6 +469,11 @@ function apiSubmit(sub, params, callback, isFile = false) {
466469 request_uri = JSON . stringify ( params ) ;
467470 }
468471
472+ if ( typeof force_method != "undefined" ) {
473+ console . info ( "Setting method to" , force_method . toUpperCase ( ) )
474+ method = force_method . toUpperCase ( ) ;
475+ }
476+
469477 ajax . open ( method , "/api/" + sub , true ) ;
470478
471479 if ( method != "POST" ) {
0 commit comments