File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Sources/SwiftBoost/Foundation/Extensions Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,10 @@ public extension URLSession {
5555 static func request(
5656 url: String ,
5757 method: HTTPMethod ,
58- body: [ String : Any ] ? = nil ,
58+ body: [ String : Any ? ] ? = nil ,
5959 contentTypeHeader: ContentType ? = nil ,
60- completion: @escaping ( AppError ? , Data ? , HTTPURLResponse ? ) -> Void )
61- {
60+ completion: @escaping ( AppError ? , Data ? , HTTPURLResponse ? ) -> Void
61+ ) {
6262 guard let url = URL ( string: url) else {
6363 completion ( AppError . invalidURL ( url) , nil , nil )
6464 return
@@ -73,7 +73,10 @@ public extension URLSession {
7373 }
7474
7575 // Body
76- if let body {
76+ if var body = body {
77+
78+ body = body. compactMapValues { $0 } // delete `nil` values
79+
7780 do {
7881 let jsonData = try JSONSerialization . data ( withJSONObject: body, options: [ ] )
7982 request. httpBody = jsonData
You can’t perform that action at this time.
0 commit comments