Skip to content

Commit 8ba7085

Browse files
committed
fix(ios): correctly send JSON body with null values
1 parent 022f4f3 commit 8ba7085

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/request.ios.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,17 +352,17 @@ export function createRequest(opts: HttpsRequestOptions, useLegacy: boolean = tr
352352

353353
let dict = null;
354354
if (opts.body) {
355-
dict = bodyToNative(opts.body);
355+
dict = NSJSONSerialization.JSONObjectWithDataOptionsError(NSString.stringWithString(JSON.stringify(opts.body)).dataUsingEncoding(NSUTF8StringEncoding), 0);
356356
} else if (opts.content) {
357-
dict = opts.content;
357+
dict = NSJSONSerialization.JSONObjectWithDataOptionsError(NSString.stringWithString(opts.content).dataUsingEncoding(NSUTF8StringEncoding), 0);
358358
}
359359

360360
manager.requestSerializer.timeoutInterval = opts.timeout ? opts.timeout : 10;
361361

362362
const progress = opts.onProgress
363363
? (progress: NSProgress) => {
364-
opts.onProgress(progress.completedUnitCount, progress.totalUnitCount);
365-
}
364+
opts.onProgress(progress.completedUnitCount, progress.totalUnitCount);
365+
}
366366
: null;
367367
let task: NSURLSessionDataTask;
368368
const tag = opts.tag;

0 commit comments

Comments
 (0)