File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed
src/BootstrapBlazor/wwwroot/modules Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change 1919 if ( headers [ 'Content-Type' ] === void 0 ) {
2020 headers [ 'Content-Type' ] = 'application/json; charset=utf-8'
2121 }
22- const contentType = headers [ 'Content-Type' ] ;
23- let postData = null ;
24- if ( data ) {
25- postData = JSON . stringify ( data ) ;
26- if ( contentType . indexOf ( 'application/x-www-form-urlencoded' ) > - 1 ) {
27- postData = new URLSearchParams ( data ) . toString ( ) ;
22+
23+ const fetchOptions = {
24+ method : method ,
25+ headers : headers
26+ }
27+
28+ if ( method === 'PUT' || method === 'POST' ) {
29+ const contentType = headers [ 'Content-Type' ] ;
30+ let postData = null ;
31+ if ( data ) {
32+ postData = JSON . stringify ( data ) ;
33+ if ( contentType . indexOf ( 'application/x-www-form-urlencoded' ) > - 1 ) {
34+ postData = new URLSearchParams ( data ) . toString ( ) ;
35+ }
36+ fetchOptions . body = postData ;
2837 }
2938 }
30- result = await fetch ( url , {
31- method : method ,
32- headers : headers ,
33- body : postData
34- } ) ;
39+ result = await fetch ( url , fetchOptions ) ;
3540 if ( toJson === true ) {
3641 result = await result . json ( )
3742 }
You can’t perform that action at this time.
0 commit comments