@@ -151,13 +151,15 @@ async function fetchServerFunction(
151151 ? createRequest ( base , id , instance , options )
152152 : args . length === 1 && args [ 0 ] instanceof FormData
153153 ? createRequest ( base , id , instance , { ...options , body : args [ 0 ] } )
154+ : args . length === 1 && args [ 0 ] instanceof URLSearchParams
155+ ? createRequest ( base , id , instance , {
156+ ...options ,
157+ body : args [ 0 ] ,
158+ headers : { ...options . headers , "Content-Type" : "application/x-www-form-urlencoded" }
159+ } )
154160 : createRequest ( base , id , instance , {
155161 ...options ,
156- body : JSON . stringify (
157- await Promise . resolve (
158- toJSONAsync ( args , { plugins } )
159- )
160- ) ,
162+ body : JSON . stringify ( await Promise . resolve ( toJSONAsync ( args , { plugins } ) ) ) ,
161163 headers : { ...options . headers , "Content-Type" : "application/json" }
162164 } ) ) ;
163165
@@ -201,14 +203,20 @@ export function createServerReference(fn: Function, id: string, name: string) {
201203 return receiver . withOptions ( { method : "GET" } ) ;
202204 }
203205 if ( prop === "withOptions" ) {
204- const url = `${ baseURL } /_server/?id=${ encodeURIComponent ( id ) } &name=${ encodeURIComponent ( name ) } `
206+ const url = `${ baseURL } /_server/?id=${ encodeURIComponent ( id ) } &name=${ encodeURIComponent (
207+ name
208+ ) } `;
205209 return ( options : RequestInit ) => {
206210 const fn = async ( ...args : any [ ] ) => {
207211 const encodeArgs = options . method && options . method . toUpperCase ( ) === "GET" ;
208212 return fetchServerFunction (
209213 encodeArgs
210- ? url + ( args . length ? `&args=${ encodeURIComponent ( JSON . stringify ( await Promise . resolve (
211- toJSONAsync ( args , { plugins } ) ) ) ) } ` : "" )
214+ ? url +
215+ ( args . length
216+ ? `&args=${ encodeURIComponent (
217+ JSON . stringify ( await Promise . resolve ( toJSONAsync ( args , { plugins } ) ) )
218+ ) } `
219+ : "" )
212220 : `${ baseURL } /_server` ,
213221 `${ id } #${ name } ` ,
214222 options ,
0 commit comments