File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -419,23 +419,30 @@ export default class ApiRequest extends LitElement {
419
419
420
420
//Form Params
421
421
if ( formParamEls . length >= 1 ) {
422
+
422
423
let formEl = requestPanelEl . querySelector ( "form" ) ;
423
424
if ( formEl . classList . contains ( "form-urlencoded" ) ) {
424
425
let formUrlParams = new URLSearchParams ( ) ;
425
426
fetchOptions . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded; charset=utf-8'
426
427
curlHeaders = curlHeaders + ` -H "Content-Type: application/x-www-form-urlencoded"` ;
427
- formParamEls . map ( function ( el ) {
428
- if ( el . value ) {
429
- formUrlParams . append ( el . dataset . pname , el . value ) ;
430
- curlForm = curlForm + ` -F "${ el . dataset . pname } =${ el . value } "` ;
431
- }
432
- } ) ;
433
428
fetchOptions . body = formUrlParams ;
434
429
}
435
- else {
436
- //fetchOptions.headers['Content-Type'] = 'multipart/form-data; charset=utf-8'
430
+ else {
431
+ //fetchOptions.headers['Content-Type'] = 'multipart/form-data' // Dont set content type for fetch, coz the browser must auto-generate boundry value too
432
+ curlHeaders = curlHeaders + ` -H "Content-Type: multipart/form-data"` ;
437
433
fetchOptions . body = new FormData ( formEl ) ;
438
434
}
435
+
436
+ formParamEls . map ( function ( el ) {
437
+ if ( el . value ) {
438
+ if ( el . type !== 'file' ) {
439
+ curlForm = curlForm + ` -F "${ el . dataset . pname } =${ el . value } "` ;
440
+ }
441
+ else {
442
+ curlForm = curlForm + ` -F "${ el . dataset . pname } =@${ el . value } "` ;
443
+ }
444
+ }
445
+ } ) ;
439
446
}
440
447
441
448
//Body Params (json/xml/text)
You can’t perform that action at this time.
0 commit comments