Skip to content

Commit 04c719a

Browse files
committed
fix: ios fix for body and POST
1 parent d2d7ab5 commit 04c719a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/https/request.ios.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,11 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
538538
} else {
539539
let dict = null;
540540
if (opts.body) {
541-
dict = NSJSONSerialization.JSONObjectWithDataOptionsError(NSString.stringWithString(JSON.stringify(opts.body)).dataUsingEncoding(NSUTF8StringEncoding), 0 as any);
541+
if (typeof opts.body === 'string') {
542+
dict = NSJSONSerialization.JSONObjectWithDataOptionsError(NSString.stringWithString(opts.body).dataUsingEncoding(NSUTF8StringEncoding), 0 as any);
543+
} else {
544+
dict = NSJSONSerialization.JSONObjectWithDataOptionsError(NSString.stringWithString(JSON.stringify(opts.body)).dataUsingEncoding(NSUTF8StringEncoding), 0 as any);
545+
}
542546
} else if (typeof opts.content === 'string') {
543547
dict = NSJSONSerialization.JSONObjectWithDataOptionsError(NSString.stringWithString(opts.content).dataUsingEncoding(NSUTF8StringEncoding), 0 as any);
544548
}

0 commit comments

Comments
 (0)